Skip to content

Commit

Permalink
Add progress bar in image and video demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
JiayuXu0 committed Oct 6, 2022
1 parent cfd17fb commit 77845bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions demo/image_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import mmcv
from mmdet.apis import inference_detector, init_detector
from mmengine.utils import ProgressBar

from mmyolo.registry import VISUALIZERS
from mmyolo.utils import register_all_modules
Expand Down Expand Up @@ -85,6 +86,8 @@ def main(args):
visualizer.dataset_meta = model.dataset_meta

files = LoadFiles(args.img)
progress_bar = ProgressBar(len(files))

for file in files:
result = inference_detector(model, file)
img = mmcv.imread(file)
Expand All @@ -99,6 +102,7 @@ def main(args):
wait_time=0,
out_file=os.path.join(args.out_path, file_name),
pred_score_thr=args.score_thr)
progress_bar.update()


if __name__ == '__main__':
Expand Down
5 changes: 5 additions & 0 deletions demo/video_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import cv2
import mmcv
from mmdet.apis import inference_detector, init_detector
from mmengine.utils import ProgressBar

from mmyolo.registry import VISUALIZERS
from mmyolo.utils import register_all_modules
Expand Down Expand Up @@ -51,6 +52,8 @@ def main():
args.out, fourcc, video_reader.fps,
(video_reader.width, video_reader.height))

progress_bar = ProgressBar(len(video_reader))

for frame in video_reader:
result = inference_detector(model, frame)
if args.show:
Expand All @@ -68,6 +71,8 @@ def main():
pred_score_thr=args.score_thr)
if args.out:
video_writer.write(visualizer.get_image())
progress_bar.update()

if video_writer:
video_writer.release()
cv2.destroyAllWindows()
Expand Down

0 comments on commit 77845bb

Please sign in to comment.