LukasBommes / mvmed-tracker

Multi-Object Tracker for the H.264 and MPEG-4 Compressed Domain.
MIT License
16 stars 8 forks source link

missing labelmap.json file #2

Open bhargav-sudo opened 2 years ago

bhargav-sudo commented 2 years ago

Hi, Thanks for the project. I am trying to track with object detector models provided in the https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf1_detection_zoo.md . But while i am running this it says it doesn't have labelmap.json file.

Where can I find labelmap.json file??

Although I created a json file like this.

{"label" : "person" , "index" : 0}

Ir returns the below error.

Traceback (most recent call last): File "track.py", line 113, in detections = detector.detect(frame) File "/mvmed_tracker/detector.py", line 215, in detect output_dict = self._get_output_dict(frame) File "/mvmed_tracker/detector.py", line 329, in _get_output_dict cls_labels.append(self._class_index_to_label(cls_idx)) File "/mvmed_tracker/detector.py", line 81, in _class_index_to_label class_label = [map["label"] for map in self.label_map if map["index"] == class_index][0] File "/mvmed_tracker/detector.py", line 81, in class_label = [map["label"] for map in self.label_map if map["index"] == class_index][0] TypeError: string indices must be integers

Thanks.

LukasBommes commented 2 years ago

Hey bhargav-sudo,

thanks for pointing this out. I will take a look into why the labelmap is not contained in the repo.

As of now, please provide the labelmaps as list of dicts (instead of a dict). Ie., your labelmap.json should look as follows:

[{
    "label": "person",
    "index": 0
}]
bhargav-sudo commented 2 years ago

Hi @LukasBommes

Thanks for the quick response. I had created labelmap file as you said. But it throws error like this.

Traceback (most recent call last): File "track.py", line 113, in detections = detector.detect(frame) File "/mvmed_tracker/detector.py", line 216, in detect output_dict = self._get_output_dict(frame) File "/mvmed_tracker/detector.py", line 330, in _get_output_dict cls_labels.append(self._class_index_to_label(cls_idx)) File "/mvmed_tracker/detector.py", line 82, in _class_index_to_label class_label = [map["label"] for map in self.label_map if map["index"] == class_index][0] IndexError: list index out of range

LukasBommes commented 2 years ago

Can you print which class_index leads to this error? Probably, there should be an additional class for the background. So, your labelmap should contain a person and a background class.

bhargav-sudo commented 2 years ago

Hi @LukasBommes I had solve the above issue by commenting in line 80. The bold last part in below line.

class_label = [map["label"] for map in self.label_map if map["index"] == class_index]#[0] This last part.

It works after that. But whenever I need to use more labels in json file. I need to uncomment it. Thanks for the project. It really making interest to learn. :100:

But please check why the label map file isn't available in the repo.

LukasBommes commented 2 years ago

If you fix it like this, then you loose the ability to classify more than a single class as you have already pointed out. Can you try the following labelmap?

[{
  "label": "background",
  "index": 0
},
{
   "label": "person",
   "index": 1
}]

It canbe that background and person have to be swapped.