-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
author : justniub #212
base: main
Are you sure you want to change the base?
author : justniub #212
Conversation
date : 20210412 modify : solve the save bug in demo/demo.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all, thank you for your contribution. But there are many small problems in the code. I'm afraid that you may need to pay attention to the format when submitting a PR.
save_folder = args.save_path if args.save_path else os.path.join(cfg.save_dir, | ||
time.strftime("%Y_%m_%d_%H_%M_%S", | ||
current_time)) | ||
if not os.path.exists(save_folder): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use mkdir function in nanodet.util
logs.txt
Outdated
@@ -0,0 +1 @@ | |||
INFO:root:Press "Esc", "q" or "Q" to exit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this file.
demo/demo.py
Outdated
args = parser.parse_args() | ||
|
||
# print(args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this.
demo/demo.py
Outdated
@@ -8,7 +8,7 @@ | |||
from nanodet.util import load_model_weight | |||
from nanodet.data.transform import Pipeline | |||
|
|||
image_ext = ['.jpg', '.jpeg', '.webp', '.bmp', '.png'] | |||
image_ext = ['.jpg', '.jpeg', '.webp', '.bmp', '.png','.JPG'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think .JPG is a necessary file extension. But if you think this is useful, other file extensions should also have a uppercase version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do something like this:
image_ext = ['.jpg', '.jpeg', '.webp', '.bmp', '.png']
image_ext += [x.upper() for x in image_ext]
for image_name in files: | ||
meta, res = predictor.inference(image_name) | ||
result_image = predictor.visualize(res, meta, cfg.class_names, 0.35) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many unnecessary line breaks.
demo/demo.py
Outdated
current_time)) | ||
if not os.path.exists(save_folder): | ||
os.makedirs(save_folder) | ||
print(fr"make the save folder: {save_folder}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace print with logging.info
demo/demo.py
Outdated
save_path = os.path.join(save_folder, args.path.split('/')[-1]) if args.demo == 'video' else os.path.join(save_folder, 'camera.mp4') | ||
print(f'save_path is {save_path}') | ||
vid_writer = cv2.VideoWriter(save_path, cv2.VideoWriter_fourcc(*'mp4v'), fps, (int(width), int(height))) | ||
print(args.save_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace print with logging.info
demo/demo.py
Outdated
save_folder, 'camera.mp4') | ||
|
||
vid_writer = cv2.VideoWriter(save_path, -1, fps, (int(width), int(height))) | ||
print(fr"make the save folder: {save_folder}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace print with logging.info
demo/demo.py
Outdated
while True: | ||
ret_val, frame = cap.read() | ||
if ret_val: | ||
meta, res = predictor.inference(frame) | ||
result_frame = predictor.visualize(res, meta, cfg.class_names, 0.35) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many unnecessary line breaks.
demo/demo.py
Outdated
if args.save_result: | ||
vid_writer.write(result_frame) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many unnecessary line breaks.
date : 20210412
modify : solve the save bug in demo/demo.py