hysts HF Staff commited on
Commit
a968fd4
·
1 Parent(s): b8c782f
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -4,12 +4,14 @@ from __future__ import annotations
4
 
5
  import argparse
6
  import functools
 
7
  import pathlib
8
  import subprocess
9
 
10
- subprocess.call('pip uninstall -y opencv-python'.split())
11
- subprocess.call('pip uninstall -y opencv-python-headless'.split())
12
- subprocess.call('pip install opencv-python-headless==4.5.5.62'.split())
 
13
 
14
  import cv2
15
  import face_alignment
@@ -49,8 +51,12 @@ def detect(
49
 
50
  res = image.copy()
51
  for pts in preds:
 
 
 
 
52
  for pt in np.round(pts).astype(int):
53
- cv2.circle(res, tuple(pt), 2, (0, 255, 0), cv2.FILLED)
54
  return res
55
 
56
 
 
4
 
5
  import argparse
6
  import functools
7
+ import os
8
  import pathlib
9
  import subprocess
10
 
11
+ if os.environ.get('SYSTEM') == 'spaces':
12
+ subprocess.call('pip uninstall -y opencv-python'.split())
13
+ subprocess.call('pip uninstall -y opencv-python-headless'.split())
14
+ subprocess.call('pip install opencv-python-headless==4.5.5.62'.split())
15
 
16
  import cv2
17
  import face_alignment
 
51
 
52
  res = image.copy()
53
  for pts in preds:
54
+ tl = pts.min(axis=0)
55
+ br = pts.max(axis=0)
56
+ size = (br - tl).max()
57
+ radius = max(2, int(3 * size / 256))
58
  for pt in np.round(pts).astype(int):
59
+ cv2.circle(res, tuple(pt), radius, (0, 255, 0), cv2.FILLED)
60
  return res
61
 
62