forked from sthanhng/yoloface
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create face detection in image with gpu
- Loading branch information
Showing
1 changed file
with
61 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import argparse | ||
|
||
from PIL import Image | ||
from YOLO import YOLO | ||
|
||
|
||
##################################################################### | ||
def get_args(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('--model', type=str, default='', | ||
help='path to model weights file') | ||
parser.add_argument('--anchors', type=str, default='', | ||
help='path to anchor definitions') | ||
parser.add_argument('--classes', type=str, default='', | ||
help='path to class definitions') | ||
parser.add_argument('--score', type=float, default='', | ||
help='the score threshold') | ||
parser.add_argument('--iou', type=float, default='', | ||
help='the iou threshold') | ||
parser.add_argument('--img-size', type=list, action='store', | ||
default=(416, 416), help='input image size') | ||
parser.add_argument('--image', default=False, action="store_true", | ||
help='image detection mode') | ||
parser.add_argument('--output', type=str, | ||
default='', help='image/video output path') | ||
args = parser.parse_args() | ||
return args | ||
|
||
|
||
def detect_img(yolo): | ||
while True: | ||
img = input('[i] ==> Input image filename: ') | ||
try: | ||
image = Image.open(img) | ||
except: | ||
print('[!] ==> Open Error! Try again!') | ||
continue | ||
else: | ||
res_image = yolo.detect_image(image) | ||
res_image.show() | ||
|
||
yolo.close_session() | ||
|
||
|
||
def _main(): | ||
# Get the arguments | ||
args = get_args() | ||
|
||
if args.image: | ||
# Image detection mode | ||
print('[i] ==> Image detection mode\n') | ||
detect_img(YOLO(args)) | ||
else: | ||
print('[i] ==> Video detection mode\n') | ||
# Call the detect_video method here | ||
|
||
print('Well done!!!') | ||
|
||
|
||
if __name__ == "__main__": | ||
_main() |