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.

Output COCO-style JSON Annotation for single images in eval.py

See original GitHub issue

Hi @dbolya, thank you for this great piece of software. I already used it, to generate images with drawn masks using the inference script eval.py on single images and folders. This worked fine. Now after getting the images, i wanted to programmatically use the inference results, which is why i would need a coco style json file instead of an png as an output.

I already saw there is the args.output_coco_json parameter, but looking at the code, it seems to only work when evaluating whole datasets (with ground truth available?) and not for single images or folders of single images, without annotations.

What i would like to do, is calling eval.py similar to this:

--config=yolact_base_config
--trained_model=weights/yolact_base_54_800000.pth
--output_coco_json
--bbox_det_file=myimage.bbox.json
--mask_det_file=myimage.mask.json
--score_threshold=0.2 --top_k=15
--image=myimage.png:myimage_out.png

(with only myimage.png, yolact_base_config and weights/yolact_base_54_800000.pth already existing.)

i also tried putting the following additional parameters into the arguments:

--mask_proto_debug
--dataset=coco2017_testdev_dataset

but they did not help, as the coco style dumping function in eval.py (https://github.com/dbolya/yolact/blob/02bde378e98cd7e2831639ff782c1f5a5046771a/eval.py#L960) does not get executed when --image is set (see https://github.com/dbolya/yolact/blob/02bde378e98cd7e2831639ff782c1f5a5046771a/eval.py#L855).

Is there any other way i can use arguments to reveice a coco style json file with annotations for a single image or a folder of images? If not, please regard this as a feature request 😃 Kind Regards Alexander

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
downhillercommented, Aug 19, 2020

The way --output_coco_json works right now is it operates on a dataset (which doesn’t need to have ground truth). So you need to give a --dataset parameter instead of an --image parameter. The dataset you use doesn’t need annotations, simply create a COCO dataset with just images and an empty annotation array and follow the dataset definition of coco2017_testdev_dataset.

For single images, this is kind of cumbersome, but for large batches it probably works fine? This feature was intended for submission to the COCO eval servers so that’s why it’s so roundabout. Let me know if this is indeed too cumbersome, and I can add --output_coco_json support to --image.

It’s too cumbersome, please add json output to --image use 😉

(I’ve created my own dataset, but if target.shape[0] == 0: is failing, as target = []. What am I doing wrong?)

0reactions
takwaaacommented, Jun 13, 2022

The way --output_coco_json works right now is it operates on a dataset (which doesn’t need to have ground truth). So you need to give a --dataset parameter instead of an --image parameter. The dataset you use doesn’t need annotations, simply create a COCO dataset with just images and an empty annotation array and follow the dataset definition of coco2017_testdev_dataset.

For single images, this is kind of cumbersome, but for large batches it probably works fine? This feature was intended for submission to the COCO eval servers so that’s why it’s so roundabout. Let me know if this is indeed too cumbersome, and I can add --output_coco_json support to --image.

I followed the steps and I could use the dataset parameter as suggested , but now i have 2 questions: After running the script eval.py as follows :

python eval.py --trained_model=weights/yolact_plus_resnet50_generated_dwg_3599_360000.pth --config yolact_resnet50_generated_dwg_config --output_coco_json --score_threshold=0.1 --top_k=30 --dataset=generated_Test_datasetfiles

as an output i got two files under results/ :

  • mask_detections.json
  • bbox_detections.json
  1. Is this the correct output ? isn’t there a way that i could find all the resulted annotations of the tested dataset in one single file rather than being divided in Two files ? ( all the annotations results (bbox and segmentation) would be written in the empty annotation array of the annotations.json file of the custom test dataset ) ?

  2. I am getting the segmentation in encoded format: image

Why is that ? and is there a way to deal with it?

Thanks,

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to work with object detection datasets in COCO format
The dataset is stored in a directory containing your raw image data and a single json file that contains all of the annotations,...
Read more >
Create MS COCO style dataset - python - Stack Overflow
I'm working on a python library which has many useful classes and functions for doing this. It's called Image Semantics.
Read more >
Hee Joon Yoon / yoloact - GitLab
A simple, fully convolutional model for real-time instance segmentation. This is the code for our papers:.
Read more >
NuScenes Dataset for 3D Object Detection
json : training dataset coco-style info. This file organizes image-based data into three categories (keys): 'categories' , 'images' , ...
Read more >
Custom Dataset — OpenPifPaf Guide
For the ApolloCar3D Dataset, we created a module called apollo_kp.py ... and include in the json file a single annotation (instance) from a...
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