-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40bd7b1
commit 5c51f1a
Showing
13 changed files
with
453 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
import logging | ||
import os | ||
from argparse import ArgumentParser | ||
|
||
from mmengine.logging import print_log | ||
|
||
from mmdet3d.apis import MonoDet3DInferencer | ||
|
||
|
||
def parse_args(): | ||
parser = ArgumentParser() | ||
parser.add_argument('img', help='Image file') | ||
parser.add_argument('infos', help='Infos file with annotations') | ||
parser.add_argument('model', help='Config file') | ||
parser.add_argument('weights', help='Checkpoint file') | ||
parser.add_argument( | ||
'--device', default='cuda:0', help='Device used for inference') | ||
parser.add_argument( | ||
'--cam-type', | ||
type=str, | ||
default='CAM_BACK', | ||
help='choose camera type to inference') | ||
parser.add_argument( | ||
'--pred-score-thr', | ||
type=float, | ||
default=0.3, | ||
help='bbox score threshold') | ||
parser.add_argument( | ||
'--out-dir', | ||
type=str, | ||
default='outputs', | ||
help='Output directory of prediction results.') | ||
parser.add_argument( | ||
'--show', | ||
action='store_true', | ||
help='Show online visualization results') | ||
parser.add_argument( | ||
'--wait_time', | ||
type=float, | ||
default=-1, | ||
help='The interval of show (s). Demo will be blocked in showing' | ||
'results, if wait_time is -1. Defaults to -1.') | ||
parser.add_argument( | ||
'--no-save-vis', | ||
action='store_true', | ||
help='Do not save detection vis results') | ||
parser.add_argument( | ||
'--no-save-pred', | ||
action='store_true', | ||
help='Do not save detection json results') | ||
parser.add_argument( | ||
'--print-result', | ||
action='store_true', | ||
help='Whether to print the results.') | ||
call_args = vars(parser.parse_args()) | ||
|
||
call_args['inputs'] = dict( | ||
img=call_args.pop('img'), infos=call_args.pop('infos')) | ||
call_args.pop('cam_type') | ||
|
||
if call_args['no_save_vis'] and call_args['no_save_pred']: | ||
call_args['out_dir'] = '' | ||
|
||
init_kws = ['model', 'weights', 'device'] | ||
init_args = {} | ||
for init_kw in init_kws: | ||
init_args[init_kw] = call_args.pop(init_kw) | ||
|
||
# NOTE: If your operating environment does not have a display device, | ||
# (e.g. a remote server), you can save the predictions and visualize | ||
# them in local devices. | ||
if os.environ.get('DISPLAY') is None and call_args['show']: | ||
print_log( | ||
'Display device not found. `--show` is forced to False', | ||
logger='current', | ||
level=logging.WARNING) | ||
call_args['show'] = False | ||
|
||
return init_args, call_args | ||
|
||
|
||
def main(): | ||
# TODO: Support inference of point cloud numpy file. | ||
init_args, call_args = parse_args() | ||
|
||
inferencer = MonoDet3DInferencer(**init_args) | ||
inferencer(**call_args) | ||
|
||
if call_args['out_dir'] != '' and not (call_args['no_save_vis'] | ||
and call_args['no_save_pred']): | ||
print_log( | ||
f'results have been saved at {call_args["out_dir"]}', | ||
logger='current') | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
import logging | ||
import os | ||
from argparse import ArgumentParser | ||
|
||
from mmengine.logging import print_log | ||
|
||
from mmdet3d.apis import MultiModalityDet3DInferencer | ||
|
||
|
||
def parse_args(): | ||
parser = ArgumentParser() | ||
parser.add_argument('pcd', help='Point cloud file') | ||
parser.add_argument('img', help='Image file') | ||
parser.add_argument('infos', help='Infos file with annotations') | ||
parser.add_argument('model', help='Config file') | ||
parser.add_argument('weights', help='Checkpoint file') | ||
parser.add_argument( | ||
'--device', default='cuda:0', help='Device used for inference') | ||
parser.add_argument( | ||
'--cam-type', | ||
type=str, | ||
default='CAM_BACK', | ||
help='choose camera type to inference') | ||
parser.add_argument( | ||
'--pred-score-thr', | ||
type=float, | ||
default=0.3, | ||
help='bbox score threshold') | ||
parser.add_argument( | ||
'--out-dir', | ||
type=str, | ||
default='outputs', | ||
help='Output directory of prediction results.') | ||
parser.add_argument( | ||
'--show', | ||
action='store_true', | ||
help='Show online visualization results') | ||
parser.add_argument( | ||
'--wait_time', | ||
type=float, | ||
default=-1, | ||
help='The interval of show (s). Demo will be blocked in showing' | ||
'results, if wait_time is -1. Defaults to -1.') | ||
parser.add_argument( | ||
'--no-save-vis', | ||
action='store_true', | ||
help='Do not save detection vis results') | ||
parser.add_argument( | ||
'--no-save-pred', | ||
action='store_true', | ||
help='Do not save detection json results') | ||
parser.add_argument( | ||
'--print-result', | ||
action='store_true', | ||
help='Whether to print the results.') | ||
call_args = vars(parser.parse_args()) | ||
|
||
call_args['inputs'] = dict( | ||
points=call_args.pop('pcd'), | ||
img=call_args.pop('img'), | ||
infos=call_args.pop('infos')) | ||
call_args.pop('cam_type') | ||
|
||
if call_args['no_save_vis'] and call_args['no_save_pred']: | ||
call_args['out_dir'] = '' | ||
|
||
init_kws = ['model', 'weights', 'device'] | ||
init_args = {} | ||
for init_kw in init_kws: | ||
init_args[init_kw] = call_args.pop(init_kw) | ||
|
||
# NOTE: If your operating environment does not have a display device, | ||
# (e.g. a remote server), you can save the predictions and visualize | ||
# them in local devices. | ||
if os.environ.get('DISPLAY') is None and call_args['show']: | ||
print_log( | ||
'Display device not found. `--show` is forced to False', | ||
logger='current', | ||
level=logging.WARNING) | ||
call_args['show'] = False | ||
|
||
return init_args, call_args | ||
|
||
|
||
def main(): | ||
# TODO: Support inference of point cloud numpy file. | ||
init_args, call_args = parse_args() | ||
|
||
inferencer = MultiModalityDet3DInferencer(**init_args) | ||
inferencer(**call_args) | ||
|
||
if call_args['out_dir'] != '' and not (call_args['no_save_vis'] | ||
and call_args['no_save_pred']): | ||
print_log( | ||
f'results have been saved at {call_args["out_dir"]}', | ||
logger='current') | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.