Object Detection Finetuning Tutorial multiclass with own Data

Hey there,
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?
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?

Thanks a lot for your help!

Are u following this example? https://pytorch.org/docs/stable/torchvision/models.html#mask-r-cnn. If yes, I did the same last week and it worked fine to me. Please note the method def get_model_instance_segmentation(num_classes).

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.

No, I did this tutorial https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html

I would like to have just my 5 classes (+backgraound).

Yep, that worked for me as well.

If your Custom Data set working fine? I can share mine, if you used Labelme to create annotation.

Did you test the data loader?

If both above are ok, so you just need to run the training

Can you tell me what code I have to add?
If I start training I get this error:

/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 "

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=)}

An exception has occurred, use %tb to see the full traceback.

SystemExit: 1

I created my Label with Labelbox. How can I ttest my data loader? If I print the pictures, they are shown correctly.

You can test the dataset with this:

len(dataset)
dataset[0]

And the data loader with this:

next(iter(dataloader))

The Dataset is shown, but I do not understand all the numbers, arrays and matrices.

I dont have a dataloader. I uploaded my .zip file with all the pictures and unziped it.

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.

Probably it’s because dataset from tutorial is only for one class detection.
And it doesn’t raise an error if you have several classes on image.
I’m looking for example of training data for multicalss detection too.
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
p.s. pytorch tutorials are misleading