Spaces:
Build error
Build error
onipot
commited on
Commit
·
611c38a
1
Parent(s):
cd74713
update description
Browse files
app.py
CHANGED
@@ -14,17 +14,16 @@ torch.hub.download_url_to_file(age_model, 'age_model.pt')
|
|
14 |
sys.path.append("./")
|
15 |
sys.path.append("./yolov5")
|
16 |
|
17 |
-
age_model_ts = torch.jit.load("age_model.pt")
|
18 |
-
|
19 |
from yolov5.detect import predict, load_yolo_model
|
20 |
|
21 |
-
#
|
22 |
-
|
23 |
model, stride, names, pt, jit, onnx, engine = load_yolo_model("face_model.pt", imgsz=[320,320])
|
|
|
|
|
|
|
24 |
|
25 |
def run_yolo(img):
|
26 |
|
27 |
-
#img0 = Image.open(img.name).convert("RGB")
|
28 |
img_path = img.name # ["name"]
|
29 |
img0 = Image.open(img_path).convert("RGB")
|
30 |
draw = ImageDraw.Draw(img0)
|
@@ -35,8 +34,6 @@ def run_yolo(img):
|
|
35 |
detections : list[Detection] = []
|
36 |
for k, (bboxes, img) in enumerate(predictions):
|
37 |
|
38 |
-
#print(bboxes)
|
39 |
-
# exp.imgs.append(img_info)
|
40 |
for i, bbox in enumerate(bboxes):
|
41 |
det = Detection(
|
42 |
(k+1)*(i+1),
|
@@ -55,7 +52,7 @@ def run_yolo(img):
|
|
55 |
detections.append(det)
|
56 |
draw.rectangle(((det.xmin, det.ymin), (det.xmax, det.ymax)), fill=None, outline=(255,255,255))
|
57 |
draw.rectangle(((det.xmin, det.ymin - 10), (det.xmax, det.ymin)), fill=(255,255,255))
|
58 |
-
draw.text((det.xmin, det.ymin - 10), det.class_name, fill=(0,0,0), font=
|
59 |
|
60 |
return img0
|
61 |
|
@@ -63,12 +60,15 @@ inputs = gr.inputs.Image(type='file', label="Input Image")
|
|
63 |
outputs = gr.outputs.Image(type="pil", label="Output Image")
|
64 |
|
65 |
title = "AgeGuesser"
|
66 |
-
description = "Guess the age of a person!"
|
67 |
-
article = """
|
68 |
-
|
|
|
|
|
|
|
69 |
<ul>
|
70 |
<li>
|
71 |
-
<a href='https://link.springer.com/chapter/10.1007/978-3-030-89131-2_25'>
|
72 |
</li>
|
73 |
<li>
|
74 |
<a href='https://www.researchgate.net/publication/355777953_Real-Time_Age_Estimation_from_Facial_Images_Using_YOLO_and_EfficientNet'>Paper</a>
|
@@ -77,6 +77,21 @@ article = """A fully automated system based on YOLOv5 and EfficientNet to perfor
|
|
77 |
<a href='https://github.com/ai-hazard/AgeGuesser-train'>Github</a>
|
78 |
</li>
|
79 |
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
"""
|
81 |
|
82 |
examples = [['images/1.jpg'], ['images/2.jpg'], ['images/3.jpg'], ['images/4.jpg'], ['images/5.jpg'], ]
|
|
|
14 |
sys.path.append("./")
|
15 |
sys.path.append("./yolov5")
|
16 |
|
|
|
|
|
17 |
from yolov5.detect import predict, load_yolo_model
|
18 |
|
19 |
+
# Load Models
|
|
|
20 |
model, stride, names, pt, jit, onnx, engine = load_yolo_model("face_model.pt", imgsz=[320,320])
|
21 |
+
age_model_ts = torch.jit.load("age_model.pt")
|
22 |
+
|
23 |
+
roboto_font = ImageFont.truetype("Roboto-Regular.ttf")
|
24 |
|
25 |
def run_yolo(img):
|
26 |
|
|
|
27 |
img_path = img.name # ["name"]
|
28 |
img0 = Image.open(img_path).convert("RGB")
|
29 |
draw = ImageDraw.Draw(img0)
|
|
|
34 |
detections : list[Detection] = []
|
35 |
for k, (bboxes, img) in enumerate(predictions):
|
36 |
|
|
|
|
|
37 |
for i, bbox in enumerate(bboxes):
|
38 |
det = Detection(
|
39 |
(k+1)*(i+1),
|
|
|
52 |
detections.append(det)
|
53 |
draw.rectangle(((det.xmin, det.ymin), (det.xmax, det.ymax)), fill=None, outline=(255,255,255))
|
54 |
draw.rectangle(((det.xmin, det.ymin - 10), (det.xmax, det.ymin)), fill=(255,255,255))
|
55 |
+
draw.text((det.xmin, det.ymin - 10), det.class_name, fill=(0,0,0), font=roboto_font)
|
56 |
|
57 |
return img0
|
58 |
|
|
|
60 |
outputs = gr.outputs.Image(type="pil", label="Output Image")
|
61 |
|
62 |
title = "AgeGuesser"
|
63 |
+
description = "Guess the age of a person from a facial image!"
|
64 |
+
article = """
|
65 |
+
|
66 |
+
<p>A fully automated system based on YOLOv5 and EfficientNet to perform face detection and age estimation in real-time. </p>
|
67 |
+
|
68 |
+
<p><b>Links</b></p>
|
69 |
<ul>
|
70 |
<li>
|
71 |
+
<a href='https://link.springer.com/chapter/10.1007/978-3-030-89131-2_25'>Springer</a>
|
72 |
</li>
|
73 |
<li>
|
74 |
<a href='https://www.researchgate.net/publication/355777953_Real-Time_Age_Estimation_from_Facial_Images_Using_YOLO_and_EfficientNet'>Paper</a>
|
|
|
77 |
<a href='https://github.com/ai-hazard/AgeGuesser-train'>Github</a>
|
78 |
</li>
|
79 |
</ul>
|
80 |
+
|
81 |
+
<p>Credits to my dear colleague <a href='https://www.linkedin.com/in/nicola-marvulli-904270136/'>Dott. Nicola Marvulli</a>, we've developed AgeGuesser together as part of two university exams. (Computer Vision + Deep Learning)</p>
|
82 |
+
|
83 |
+
<p>Credits to my dear professors and the <a href='https://sites.google.com/site/cilabuniba/'>CILAB</a> research group</p>
|
84 |
+
<ul>
|
85 |
+
<li>
|
86 |
+
<a href='https://sites.google.com/site/cilabuniba/people/giovanna-castellano'>Prof. Giovanna Castellano</a>
|
87 |
+
</li>
|
88 |
+
<li>
|
89 |
+
<a href='https://sites.google.com/view/gennaro-vessio/home-page'>Prof. Gennaro Vessio</a>
|
90 |
+
</li>
|
91 |
+
|
92 |
+
</ul>
|
93 |
+
|
94 |
+
|
95 |
"""
|
96 |
|
97 |
examples = [['images/1.jpg'], ['images/2.jpg'], ['images/3.jpg'], ['images/4.jpg'], ['images/5.jpg'], ]
|