Spaces:
Sleeping
Sleeping
Commit ·
c5e1ffe
1
Parent(s): 6398fcc
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ from PIL import Image, ImageDraw
|
|
| 9 |
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
|
| 10 |
print('Running on device: {}'.format(device))
|
| 11 |
|
| 12 |
-
mtcnn = MTCNN(margin=
|
| 13 |
|
| 14 |
learn = load_learner('export.pkl')
|
| 15 |
|
|
@@ -26,7 +26,7 @@ def predict(img):
|
|
| 26 |
coords = tuple(box.tolist())
|
| 27 |
pred,pred_idx,probs = learn.predict(img.crop(coords))
|
| 28 |
draw.rectangle(coords, outline=(0, 0, 0), width=1)
|
| 29 |
-
|
| 30 |
return o_img
|
| 31 |
'''
|
| 32 |
emotions["x"].append((coords[0] + coords[2])/2)
|
|
|
|
| 9 |
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
|
| 10 |
print('Running on device: {}'.format(device))
|
| 11 |
|
| 12 |
+
mtcnn = MTCNN(margin=40, keep_all=True, post_process=False, device=device)
|
| 13 |
|
| 14 |
learn = load_learner('export.pkl')
|
| 15 |
|
|
|
|
| 26 |
coords = tuple(box.tolist())
|
| 27 |
pred,pred_idx,probs = learn.predict(img.crop(coords))
|
| 28 |
draw.rectangle(coords, outline=(0, 0, 0), width=1)
|
| 29 |
+
draw.text((coords[0]-10, coords[1]-10), pred, font=ImageFont.truetype("arial"))
|
| 30 |
return o_img
|
| 31 |
'''
|
| 32 |
emotions["x"].append((coords[0] + coords[2])/2)
|