Skip to content

Commit

Permalink
create face detection in image with gpu
Browse files Browse the repository at this point in the history
  • Loading branch information
sthanhng committed Oct 17, 2018
1 parent 35b8fa0 commit c128a0f
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions yoloface_gpu.py
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()

0 comments on commit c128a0f

Please sign in to comment.