Object Detection Finetuning Tutorial multiclass with own Data

maren11: <p>Hey there,<br>
I would like to create an object detection for my own dataset wich includes 5 different classes. Therfore I checked out the Tutorial Object Detection Finetunig. How can I change the code to train the model on my own pictures and classes? Is there any example?<br>
First I imported my own Data and of course changed the names where the Data is used. But how can I change the number of classes? Right now I only changed the varialbe num_classes to 6. What else do i have to do?</p>
<p>Thanks a lot for your help!</p>

sidneib: <p>Are u following this example? <a href="https://pytorch.org/docs/stable/torchvision/models.html#mask-r-cnn" rel="nofollow noopener">https://pytorch.org/docs/stable/torchvision/models.html#mask-r-cnn</a>. If yes, I did the same last week and it worked fine to me. Please note the method <code>def get_model_instance_segmentation(num_classes)</code>.</p>
<p>Are you adding new labels or you would like to have only your new labels? I did with only 6 classes (background + 5 classes). And it worked fine.</p>

maren11: <p>No, I did this tutorial <a href="https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html" rel="nofollow noopener">https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html</a></p>
<p>I would like to have just my 5 classes (+backgraound).</p>

sidneib: <p>Yep, that worked for me as well.</p>
<p>If your Custom Data set working fine? I can share mine, if you used Labelme to create annotation.</p>
<p>Did you test the data loader?</p>
<p>If both above are ok, so you just need to run the training</p>

maren11: <p>Can you tell me what code I have to add?<br>
If I start training I get this error:</p>
<p>/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py:2854: UserWarning: The default behavior for interpolate/upsample with float scale_factor will change in 1.6.0 to align with other frameworks/libraries, and use scale_factor directly, instead of relying on the computed output size. If you wish to keep the old behavior, please set recompute_scale_factor=True. See the documentation of nn.Upsample for details. warnings.warn("The default behavior for interpolate/upsample with float scale_factor will change "</p>
<p>Loss is nan, stopping training {‘loss_classifier’: tensor(1.8139, device=‘cuda:0’, grad_fn=), ‘loss_box_reg’: tensor(nan, device=‘cuda:0’, grad_fn=), ‘loss_mask’: tensor(2.0006, device=‘cuda:0’, grad_fn=), ‘loss_objectness’: tensor(17.6392, device=‘cuda:0’, grad_fn=), ‘loss_rpn_box_reg’: tensor(19.2071, device=‘cuda:0’, grad_fn=)}</p>
<p>An exception has occurred, use %tb to see the full traceback.</p>
<p>SystemExit: 1</p>
<p>I created my Label with Labelbox. How can I ttest my data loader? If I print the pictures, they are shown correctly.</p>

sidneib: <p>You can test the dataset with this:</p>
<pre><code class="lang-auto">len(dataset)
dataset[0]
</code></pre>
<p>And the data loader with this:</p>
<pre><code class="lang-auto">next(iter(dataloader))
</code></pre>

maren11: <p>The Dataset is shown, but I do not understand all the numbers, arrays and matrices.</p>
<p>I dont have a dataloader. I uploaded my .zip file with all the pictures and unziped it.</p>

maren11: <p>Now I get a prediction but I do not have different classes. It is just a black an white prediction weather there is any object or no.</p>

Stihl: <p>Probably it’s because dataset from tutorial is only for one class detection.<br>
And it doesn’t raise an error if you have several classes on image.<br>
I’m looking for example of training data for multicalss detection too.<br>
If you solve this issue please help me, I can’t understand how to prepare data for training, I have image and mask with 5 classes on it, but how the boxes should look like if there is several objects for one class and so on… cant understand<br>
p.s. pytorch tutorials are misleading</p>