Replace copied createIndex/loadRes/evaluate in references/*/coco_eval.py by calls to original functions + contextlib.redirect_stdout to suppress prints
See original GitHub issue🚀 The feature
Motivation for the copies is only removing prints. In Python 3 this can easily be achieved by using https://docs.python.org/3/library/contextlib.html?highlight=context#contextlib.redirect_stdout around calls to evaluate/loadRes
Motivation, pitch
Less code to maintain, less code for users to copy-paste/read/understand (since currently references code is invited to be simple scaffolding for users to copy and modify)
Alternatives
No response
Additional context
Also, import torch._six
could be eliminated
cc @datumbox
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Redirecting stdout to "nothing" in python - Stack Overflow
I have a large project consisting of sufficiently large number of modules, each printing something to the standard output. Now ...
Read more >Redirecting all kinds of stdout in Python
A common task in Python (especially while testing or debugging) is to redirect sys.stdout to a stream or a file while executing some...
Read more >Suppress Print Output in Python | coding(dose)
Sometimes you don't want output at all to your screen, there are times when I'm writing a function that prints something to the...
Read more >Python 101: Redirecting stdout
The easiest way to redirect stdout in Python is to just assign it an open file object. Let's take a look at a...
Read more >Redirecting the Output of an Already Running Process
So, in this article, we'll learn different ways to redirect or copy the output of a running process. This can be useful, for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So I think: https://github.com/facebookresearch/detr/blob/eb9f7e03ed8e2ed2cd55528989fe7df890bc3fc0/datasets/coco_eval.py#L51 :
img_ids, eval_imgs = evaluate(coco_eval)
could be replaced bycoco_eval.evaluate(); eval_imgs = np.asarray(coco_eval.evalImgs).reshape(-1, len(coco_eval.params.areaRng), len(coco_eval.params.imgIds))
And then custom
evaluate()
could go.Does it make sense @fmassa?
Maybe also simplify
synchronize_between_processes
,create_common_coco_eval
andmerge
into a single