It might be easier to just cut the carpet out and re-glue new stuff back in, rather than getting starboard to fit the contours.
However, the carpet actually look like it's in decent shape - it still looks well attached, just moldy. I would at least give cleaning it a shot. Start with some soap and water, maybe something like Simple Green or Spray Nine and a stiff bristle brush and a hose. Then spray it with a diluted solution of bleach/water. It might just turn out to pretty nice - or at least much better and all it took was a little time and energy.