Testing custom model doesn't produce any visualized detection results
Closed this issue · 7 comments
Tensorflow version: 2.3.0
Use of virtual environment?: yes
Virtual environment used: Anaconda
After training and exporting a model using a custom dataset, I set out to see how well the model would work with some images I picked out specifically for testing. I used the example code provided in Object Detection From TF2 Saved Model as a template for my own dataset (commented out downloads, replaced parts with paths in my directory, etc.). However, after running the inference on each image, there is no output. Specifically, there are no images with boxes around the objects of interest. Below is the modified script I used for running the model on my images.
For reference, this is what is printed in my console when the script is run
I then decided to troubleshoot this problem by using a pre-trained model and testing it on images from the TensorFlow Model Garden. In this instance, I didn't edit the example code at all and I ended up getting the same results I did from my previous test: no images that show visualized detection results but messages that say that inferencing was performed. Could it be that the script used to initiate the entire inferencing process has an error that doesn't allow the user to view the actual detection results?
@bimmui sounds like both the pre-trained and trained models are not doing a great job at detecting the objects of interest. Try lowering the value for min_score_thresh
at line 122 in the script you provided (valid values are between 0 and 1). Are you getting any results then?
Some notes:
- My assumption, from the above debugging printout, is that you are trying to detect red plastic cups. The pre-trained models will most certainly not contain a class/label of this kind. For example, pre-trained models on the COCO dataset will contain a label for "cup".
- Have you tried monitoring the training using Tensorboard? If so, do you get decreasing losses and what are the values when you stop the training?
Thanks for replying @sglvladi.
I changed the value of min_score_thresh
from 0.3 to 0.1. I yielded the same results, so I changed it from 0.1 to 0. Unfortunately, there is still no image output given to me for both models.
To respond to your notes:
-
When I mention the use of pre-trained models, I meant that I had tested to see if the entire, unedited Python script from the example provided in Object Detection From TF2 Saved Model would work and would provide me with the same two images shown at the bottom of the tutorial. I hope this clarifies any confusion I might have through my explanation.
-
As I was training my model, I did monitor it using Tensorboard. I did receive decrease losses on the inference and when I stopped the training, the value was 0.12.
Experiencing same issue. The results does not detect anything. @bimmui you managed to fix this?
Same here
@sahalsaad @NoOneNew Unfortunately, I couldn't figure out what was wrong and decided to move my work to Google Colab. I followed a bit of this tutorial when it came to setting up Tensorflow on Colab and testing my exported model. Hope this helps.
Hello,
I experienced the same issue and have yet to figure out how to fix it, however if you just want the resultant images from running the model on your test data then you can use
plt.savefig()
rather than
plt.show()
For instance I did something like:
for i, image_path in enumerate(IMAGE_PATHS):
plt.imshow(image_np_with_detections)
plt.savefig(f"./testimages/image{i}.jpg")
Hope that helps!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.