I need a PyTorch Model which can do road segmentation on OAK-D camera.

The model provided requires Input Image Size: 896*512, which is too big for running on OAK-D camera. Thus I need to re-training it with a smaller input size(224x224) and just need the BG(background) and road classes, or if any other options available which can easily make it running on the OAK-D camera.

Does anyone know how to do this?

  • 1
    $\begingroup$ The model you're using has a couple of 2 strided convolutions. You can manipulate those in your liking, omitting some for example and finetuning the other layers.. $\endgroup$
    – Farhood ET
    Aug 18, 2021 at 5:35
  • $\begingroup$ hi @FarhoodET I am still very new to this area, could you please share a piece of code to explain what you mean?? thanks $\endgroup$
    – Franva
    Aug 18, 2021 at 8:17
  • $\begingroup$ @Franva unfortunately I think there is a lot of experimentation involved in AI. It is not simply a matter of "pls gimme teh codez" $\endgroup$
    – user253751
    Aug 18, 2021 at 10:41
  • $\begingroup$ @user253751 definitely understood it. there are huge amount of things to twist. I'm not asking for listing all of them which is impossible. But just one viable code. One can write hundreds of words to explain things, but a piece of working code is more straightforward and appreciated. $\endgroup$
    – Franva
    Aug 18, 2021 at 10:55
  • $\begingroup$ @Franva What you're trying to do is somewhat similar to Transfer Learning. You can see an example here: pyimagesearch.com/2019/06/24/…. This only changes the input shape tho, you must change the other model's dimensions to your liking and load the weights of remaining identical layers. See this for loading some but not all weights: stackoverflow.com/questions/43702323/…. $\endgroup$
    – Farhood ET
    Aug 18, 2021 at 11:28

1 Answer 1


What you need to search for is a Fully Convolutional Network, i.e. a network that use global pooling to overcome the issue of a fixed input size. Unfortunately the model you found is not fully convolutional, and every workaround to make those pre-trained weights usable implies retraining. At this point it is more convenient to find something else, or train something yourself. You can take a look at this repo which contains also a fully convolutional network for segmentation among other models (they don't seem to link to any pre-trained weights though).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .