Spaces:
Sleeping
Sleeping
Commit
·
eefbdca
1
Parent(s):
06fa033
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,14 +22,14 @@ def predict(img):
|
|
| 22 |
boxes, _ = mtcnn.detect(img)
|
| 23 |
#o_img = img.copy()
|
| 24 |
#draw = ImageDraw.Draw(o_img)
|
| 25 |
-
|
| 26 |
-
|
| 27 |
for box in boxes:
|
| 28 |
coords = tuple(box.tolist())
|
| 29 |
pred,pred_idx,probs = learn.predict(img.crop(coords))
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
return
|
| 33 |
'''
|
| 34 |
emotions["x"].append((coords[0] + coords[2])/2)
|
| 35 |
emotions["y"].append((coords[1] + coords[3])/2)
|
|
|
|
| 22 |
boxes, _ = mtcnn.detect(img)
|
| 23 |
#o_img = img.copy()
|
| 24 |
#draw = ImageDraw.Draw(o_img)
|
| 25 |
+
o_img = Image.new("RGBA", img.size, color = "white")
|
| 26 |
+
draw = ImageDraw.Draw(o_img)
|
| 27 |
for box in boxes:
|
| 28 |
coords = tuple(box.tolist())
|
| 29 |
pred,pred_idx,probs = learn.predict(img.crop(coords))
|
| 30 |
+
draw.rectangle(coords, fill=e_colors[pred], outline=(0, 0, 0), width=1)
|
| 31 |
+
draw.text((coords[0]-10, coords[1]-10), pred, font=ImageFont.truetype("arial.ttf"))
|
| 32 |
+
return o_img
|
| 33 |
'''
|
| 34 |
emotions["x"].append((coords[0] + coords[2])/2)
|
| 35 |
emotions["y"].append((coords[1] + coords[3])/2)
|