You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 21, 2023. It is now read-only.
Has somebody successfully converted cityscapes dataset filtering classes such as traffic lights, poles, etc? Indeed, I did the change of desired classes in category_instancesonly and also commented on the invalid contour warning. However, even if I did that, I still get .json output files with 0 annotations after loading all the images.
The text was updated successfully, but these errors were encountered:
To successfully convert the Cityscapes dataset while filtering specific classes such as traffic lights and poles, you can follow the steps below:
First, clone the Cityscapes scripts repository:
bash
git clone https://github.com/mcordts/cityscapesScripts.git
cd cityscapesScripts/cityscapesscripts/preparation
Modify the createTrainIdInstanceImgs.py script to filter out specific classes. In the createTrainIdInstanceImgs.py file, find the following lines:
python
Load the annotation
objects = csHelpers.loadAnnotaton(labelImgPath)
Add a filtering function after the lines mentioned above:
python
def filter_objects(objects, classes_to_keep):
filtered_objects = []
for obj in objects:
if obj.label.name in classes_to_keep:
filtered_objects.append(obj)
return filtered_objects
classes_to_keep = ['traffic light', 'pole']
objects = filter_objects(objects, classes_to_keep)
Replace the classes_to_keep list with the classes you want to keep in the final annotations.
In the json2instanceImg.py script, find the following line:
python
if not anno['regions']:
Replace the above line with the following:
python
if len(anno['regions']) == 0:
Now you can run the createTrainIdInstanceImgs.py script to generate the filtered dataset:
bash
python createTrainIdInstanceImgs.py --cityscapesPath path/to/cityscapes --outputPath path/to/output
Finally, run the json2instanceImg.py script to convert the modified annotations to JSON files:
bash
python json2instanceImg.py --cityscapesPath path/to/cityscapes --outputPath path/to/output
After following these steps, the output JSON files should contain only the filtered classes (e.g., traffic lights and poles). Make sure to replace path/to/cityscapes with the path to your Cityscapes dataset and path/to/output with your desired output path.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Has somebody successfully converted cityscapes dataset filtering classes such as traffic lights, poles, etc? Indeed, I did the change of desired classes in category_instancesonly and also commented on the invalid contour warning. However, even if I did that, I still get .json output files with 0 annotations after loading all the images.
The text was updated successfully, but these errors were encountered: