models icon indicating copy to clipboard operation
models copied to clipboard

Missing functionality of export_path in EvalConfig?

Open derekhh opened this issue 9 years ago • 5 comments

In models/object_detection/protos/eval.proto#L34, there is a field called export_path:

// Path to export detections to COCO compatible JSON format.
optional string export_path = 9 [default=''];

However, while trying to search how this field is being used, it seems there actually is no implementation of exporting detections to JSON format in the current repo: https://github.com/tensorflow/models/search?utf8=%E2%9C%93&q=export_path&type=

I've also tried to set up export_path in my EvalConfig but nothing seems to be happening so I'm guessing maybe this functionality right now is missing. Can someone help take a look?

derekhh avatar Jul 11 '17 00:07 derekhh

Sorry @derekhh - we have not exposed this behavior yet and it currently doesn't do anything. Thanks for asking!

jch1 avatar Jul 11 '17 04:07 jch1

Thanks @jch1 for your reply. :)

derekhh avatar Jul 11 '17 08:07 derekhh

Are there any updates on this? This would be very helpful!

rsandler00 avatar Feb 12 '19 20:02 rsandler00

Hi, this feature was available with the previous eval.py script but is no longer wired to the model_main.py manager. But the feature still exists in metrics/coco_evaluation.py, it is a method of the class you can call for instance line 216 in evaluate:

self.dump_detections_to_json_file("test.json")

You will also need to change utils/json_utils.py to avoid formatting problem. The function used is Dump, you can change two things:

First, define how to encode floats: (can be done globally, before the function definition also)

encoder.FLOAT_REPR = lambda o: format(o, '.%df' % 3)

and then you need to convert int objects to "true" ints for them to be serializable:

  def convert(o):
    return int(o)
  json.dump(obj, fid, default=convert, indent=4)

instead of

  json.dump(obj, fid, **params)

If you want to do things right, you can also bind this to the proto parameters :)

aloisDeLaComble avatar Mar 24 '20 14:03 aloisDeLaComble

Hi, this feature was available with the previous eval.py script but is no longer wired to the model_main.py manager. But the feature still exists in metrics/coco_evaluation.py, it is a method of the class you can call for instance line 216 in evaluate:

self.dump_detections_to_json_file("test.json")

You will also need to change utils/json_utils.py to avoid formatting problem. The function used is Dump, you can change two things:

First, define how to encode floats: (can be done globally, before the function definition also)

encoder.FLOAT_REPR = lambda o: format(o, '.%df' % 3)

and then you need to convert int objects to "true" ints for them to be serializable:

  def convert(o):
    return int(o)
  json.dump(obj, fid, default=convert, indent=4)

instead of

  json.dump(obj, fid, **params)

If you want to do things right, you can also bind this to the proto parameters :)

@aloisDeLaComble Hey how are you, I am struggling with this functionality. Could you please offer some help with this?

isspid avatar Jan 20 '22 16:01 isspid