Community
cancel
Showing results for 
Search instead for 
Did you mean: 
idata
Community Manager
364 Views

Removing labels from graph

Hi everyone,

 

I am working with a generated graph in the example given in the sdk, concretely in the video_objects example.

 

What I am facing now is that I want to remove some labels from the network, and keep only 4 of them.

 

What I have tried so far is:

 

Remove the labels from original code:

 

labels = ('background', 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor')

 

to my code:

 

labels = ('background', 'bicycle','bus', 'car','motorbike')

 

This throws the following exception, because it is still detecting me as a person, but the index of the class_id is out of range:

 

Traceback (most recent call last): File "video_objects_fake_interesting_tags.py", line 569, in <module> sys.exit(main()) File "video_objects_fake_interesting_tags.py", line 523, in main run_inference(display_image, ssd_mobilenet_graph,ctr) File "video_objects_fake_interesting_tags.py", line 224, in run_inference overlay_on_image(image_to_classify, output[base_index:base_index + 7]) File "video_objects_fake_interesting_tags.py", line 102, in overlay_on_image label_text = labels[int(class_id)] + " (" + str(percentage) + "%)" IndexError: tuple index out of range

 

Then, I tried to recreate the graph. To do this, I used the example provided in the SDK, in the SSD_mobile. The steps I followed are:

 

     

  • Change the labels.txt and keep the labels of my interest
  •  

  • Change the num_classes in MobileNetSSD_deploy.prototxt for the appropiate number.
  •  

  • Run make all
  •  

 

Of course it fails because the num_output is not correct, but I don't know which one would be the correct, or if the procedure is the appropriate.

 

The exception that I got is:

 

F0903 10:01:59.411049 2634 detection_output_layer.cpp:166] Check failed: num_priors_ * num_classes_ == bottom[1]->channels() (9585 vs. 40257) Number of priors must match number of confidence predictions.

 

Can anyone give me some guidance on how to modify the number of classes provided? This would be very helpful, since for example, a motorbike is often detected as a person, but I do not want to detect persons

 

Best regards
Tags (1)
0 Kudos
1 Reply
idata
Community Manager
74 Views

In order to help anyone reading this, the next step that I will follow is to retrain a caffe SSD_Mobilenet with my classes. These classes are part of the VOC Dataset, so I will follow the following guide:

 

https://github.com/yuanyuanli85/caffe/tree/ssd_x10

 

Note that this is a fork from the official caffe repository.

 

What I am trying to do now is to retrain for 5 classes:

 

0: background

 

1: bicycle

 

2: bus

 

3: car

 

4: motorbike

 

So after I have my model trained, I will try to export as a NCS graph and run it on my original script. I will come back with the results.

 

In the meantime, if anyone reading this thinks there are other steps that make this process faster, please don't hesitate posting

 

Thanks in advance!

Reply