question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not detecting the custom object

See original GitHub issue

have trained the model on about 126 images, 30% images contain two objects in a image

from detecto import core, utils, visualize


dataset = core.Dataset('../custom_dataset/')
model = core.Model(['stamp'])

model.fit(dataset)
model.save('model_weights_3.pth')
print(f'[INFO] Model Saved successfully!')
image = utils.read_image('../custom_dataset/page-15.jpg')
predictions = model.predict(image)
print(predictions)

Output:

/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 "
[INFO] Model Saved successfully!
([], tensor([], size=(0, 4)), tensor([]))

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
prasad01dalavicommented, May 18, 2020

you were absolutely right! there is a problem in dataset. one of the xml file filename was not matching with image name. i removed them, rechecked the dataset and file names.

continued with pip install detecto

and boom, it predicted my object with 0.96 confidence…thanks alot

0reactions
alankbicommented, May 18, 2020

@prasad01dalavi so you’re saying the error goes away when you run it with pip install detecto? If so, can you try the suggestions in my first comment again regarding setting verbose=True to see what the model loss is while training? Blank tensors are a sign that your model might not be trained well enough.

@jagilley spent some time going through your Drive folder to see if I could get it to work (I created a Colab file which you can browse through, but it’s very messy). It seems like there’s some issue with your dataset for some reason, which is causing nan losses to come up every time during training:

{'loss_classifier': tensor(nan, device='cuda:0', grad_fn=<NllLossBackward>), 'loss_box_reg': tensor(nan, device='cuda:0', grad_fn=<DivBackward0>), 'loss_objectness': tensor(nan, device='cuda:0', grad_fn=<BinaryCrossEntropyWithLogitsBackward>), 'loss_rpn_box_reg': tensor(inf, device='cuda:0', grad_fn=<DivBackward0>)}

I’m not sure why this is the case, but I can try looking deeper into it over the next few days. In the meantime though, hopefully this helps a bit in clearing up what exactly is happening.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom trained object detection model not working #8528
Bug. I have recently trained a custom object detection model for YOLOv5 with makesense.ai . I exported as a label file, and I...
Read more >
Custom object tab not visible for Users - Salesforce Help
In Salesforce Classic UI · The tab may be hidden for the Profile. Go to the User's profile and change it to Default...
Read more >
Tensorflow GPU Custom Object Detection not working
I am building a custom model to detect two objects using tensorflow and Faster_Rcnn_inception_v2 model. For this I have used 600 images which ......
Read more >
Custom Object Detection With TensorFlow.js Possible?
I'm trying to find a way to do the training with tfjs. If not possible from scratch, I was hoping there was at...
Read more >
How to train YOLOv2 to detect custom objects
The custom object we want to detect in this article is the NFPA 704 'fire diamond'. ... Important GPU is needed to training...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found