JosephKJ/OWOD

How can I test a single image?

LLsmile opened this issue · 4 comments

For OWOD, I think it should be common to test any image in the real world. So I want to test a single image taken from my camera. But the guide in the code base seems too complicated. Is there any simple way to test a image, such as python main.py model.py test.jpg?

look at the script visualise_detections.py @LLsmile

@feifeiwei Thanks for your help. But it seems there are still some error in my code.
When I use the detectrons folder in code base, the error shows like this:
appuser@855ef1fd2347:/OWOD$ python visualise_detections.py
Failed to load OpenCL runtime
Traceback (most recent call last):
File "visualise_detections.py", line 11, in
from detectron2.engine import DefaultPredictor
File "/OWOD/detectron2/engine/init.py", line 4, in
from .train_loop import *
File "/OWOD/detectron2/engine/train_loop.py", line 12, in
from reliability.Fitters import Fit_Weibull_3P
ModuleNotFoundError: No module named 'reliability'

And when I remove the detectron2 folder and use the detection2 from official installation, the error shows like this:
python visualise_detections.py
Traceback (most recent call last):
File "visualise_detections.py", line 64, in
cfg.merge_from_file(cfg_file)
File "/home/liaolin/.local/lib/python3.6/site-packages/detectron2/config/config.py", line 69, in merge_from_file
self.merge_from_other_cfg(loaded_cfg)
File "/home/liaolin/.local/lib/python3.6/site-packages/fvcore/common/config.py", line 123, in merge_from_other_cfg
return super().merge_from_other_cfg(cfg_other)
File "/home/liaolin/.local/lib/python3.6/site-packages/yacs/config.py", line 217, in merge_from_other_cfg
_merge_a_into_b(cfg_other, self, self, [])
File "/home/liaolin/.local/lib/python3.6/site-packages/yacs/config.py", line 491, in _merge_a_into_b
raise KeyError("Non-existent config key: {}".format(full_key))
KeyError: 'Non-existent config key: OWOD'

For OWOD, I think it should be common to test any image in the real world. So I want to test a single image taken from my camera. But the guide in the code base seems too complicated. Is there any simple way to test a image, such as python main.py model.py test.jpg?


detectron2, yyds~~~~

have a try, wish it will be helpful to u....
cd demo
python demo.py --config-file ../configs/OWOD/t1/t1_test.yaml --video-input /home/xxxx/shanghai.mp4 --opt MODEL.WEIGHTS /home/xxxx/t1/model_final.pth

camera, image, video , either of them is ok,
if u don't know how to set the parameters, try like this:

python demo.py --help

or set parameters as followings:
usage: demo.py [-h] [--config-file FILE] [--webcam]
[--video-input VIDEO_INPUT] [--input INPUT [INPUT ...]]
[--output OUTPUT] [--confidence-threshold CONFIDENCE_THRESHOLD]
[--opts ...]

Detectron2 demo for builtin configs

optional arguments:
-h, --help show this help message and exit
--config-file FILE path to config file
--webcam Take inputs from webcam.
--video-input VIDEO_INPUT
Path to video file.
--input INPUT [INPUT ...]
A list of space separated input images; or a single
glob pattern such as 'directory/*.jpg'
--output OUTPUT A file or directory to save output visualizations. If
not given, will show output in an OpenCV window.
--confidence-threshold CONFIDENCE_THRESHOLD
Minimum score for instance predictions to be shown
--opts ... Modify config options using the command-line 'KEY
VALUE' pairs

Thank you @feifeiwei , @ztfmars !