-
Notifications
You must be signed in to change notification settings - Fork 86
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
70fb59e
commit ca26d3f
Showing
4 changed files
with
55 additions
and
6 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,30 @@ | ||
import os | ||
import os.path as osp | ||
import sys | ||
sys.path.insert(0, osp.join(osp.dirname(osp.abspath(__file__)), '../')) | ||
from mmdet.apis import init_detector, inference_detector, show_result_pyplot | ||
import mmcv | ||
import argparse | ||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser( | ||
description='D2Det inference demo') | ||
parser.add_argument('config', help='test config file path') | ||
parser.add_argument('checkpoint', help='checkpoint file') | ||
parser.add_argument('img_file', help='img path') | ||
parser.add_argument('--out', help='output result path') | ||
args = parser.parse_args() | ||
return args | ||
|
||
def main(): | ||
args = parse_args() | ||
# build the model from a config file and a checkpoint file | ||
model = init_detector(args.config, args.checkpoint, device='cuda:0') | ||
# test a single image | ||
result = inference_detector(model, args.img_file) | ||
# show the results | ||
show_result_pyplot(args.img_file, result, model.CLASSES, out_file=args.out) | ||
|
||
|
||
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
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