hysts HF staff commited on
Commit
70b23a5
·
1 Parent(s): d3223c3
.gitattributes CHANGED
@@ -26,3 +26,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
26
  *.zip filter=lfs diff=lfs merge=lfs -text
27
  *.zstandard filter=lfs diff=lfs merge=lfs -text
28
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
26
  *.zip filter=lfs diff=lfs merge=lfs -text
27
  *.zstandard filter=lfs diff=lfs merge=lfs -text
28
  *tfevents* filter=lfs diff=lfs merge=lfs -text
29
+ *.jpg filter=lfs diff=lfs merge=lfs -text
.gitignore DELETED
@@ -1 +0,0 @@
1
- images
 
 
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 💩
4
  colorFrom: yellow
5
  colorTo: blue
6
  sdk: gradio
7
- sdk_version: 3.19.1
8
  app_file: app.py
9
  pinned: false
10
  ---
 
4
  colorFrom: yellow
5
  colorTo: blue
6
  sdk: gradio
7
+ sdk_version: 3.36.1
8
  app_file: app.py
9
  pinned: false
10
  ---
app.py CHANGED
@@ -4,15 +4,6 @@ from __future__ import annotations
4
 
5
  import os
6
  import pathlib
7
- import shlex
8
- import subprocess
9
- import tarfile
10
-
11
- if os.environ.get('SYSTEM') == 'spaces':
12
- subprocess.call(shlex.split('pip uninstall -y opencv-python'))
13
- subprocess.call(shlex.split('pip uninstall -y opencv-python-headless'))
14
- subprocess.call(
15
- shlex.split('pip install opencv-python-headless==4.5.5.64'))
16
 
17
  import gradio as gr
18
  import huggingface_hub
@@ -25,24 +16,6 @@ mp_drawing = mp.solutions.drawing_utils
25
  TITLE = 'MediaPipe Face Detection'
26
  DESCRIPTION = 'https://google.github.io/mediapipe/'
27
 
28
- HF_TOKEN = os.getenv('HF_TOKEN')
29
-
30
-
31
- def load_sample_images() -> list[pathlib.Path]:
32
- image_dir = pathlib.Path('images')
33
- if not image_dir.exists():
34
- image_dir.mkdir()
35
- dataset_repo = 'hysts/input-images'
36
- filenames = ['001.tar', '005.tar']
37
- for name in filenames:
38
- path = huggingface_hub.hf_hub_download(dataset_repo,
39
- name,
40
- repo_type='dataset',
41
- use_auth_token=HF_TOKEN)
42
- with tarfile.open(path) as f:
43
- f.extractall(image_dir.as_posix())
44
- return sorted(image_dir.rglob('*.jpg'))
45
-
46
 
47
  def run(image: np.ndarray, model_selection: int,
48
  min_detection_confidence: float) -> np.ndarray:
@@ -64,8 +37,8 @@ model_types = [
64
  'Full-range model (best for faces within 5 meters)',
65
  ]
66
 
67
- image_paths = load_sample_images()
68
- examples = [[path.as_posix(), model_types[0], 0.5] for path in image_paths]
69
 
70
  gr.Interface(
71
  fn=run,
@@ -81,8 +54,8 @@ gr.Interface(
81
  step=0.05,
82
  value=0.5),
83
  ],
84
- outputs=gr.Image(label='Output', type='numpy'),
85
  examples=examples,
86
  title=TITLE,
87
  description=DESCRIPTION,
88
- ).launch(show_api=False)
 
4
 
5
  import os
6
  import pathlib
 
 
 
 
 
 
 
 
 
7
 
8
  import gradio as gr
9
  import huggingface_hub
 
16
  TITLE = 'MediaPipe Face Detection'
17
  DESCRIPTION = 'https://google.github.io/mediapipe/'
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  def run(image: np.ndarray, model_selection: int,
21
  min_detection_confidence: float) -> np.ndarray:
 
37
  'Full-range model (best for faces within 5 meters)',
38
  ]
39
 
40
+ image_paths = sorted(pathlib.Path('images').rglob('*.jpg'))
41
+ examples = [[path, model_types[0], 0.5] for path in image_paths]
42
 
43
  gr.Interface(
44
  fn=run,
 
54
  step=0.05,
55
  value=0.5),
56
  ],
57
+ outputs=gr.Image(label='Output'),
58
  examples=examples,
59
  title=TITLE,
60
  description=DESCRIPTION,
61
+ ).queue().launch()
images/pexels-george-dolgikh-giftpunditscom-1310522.jpg ADDED

Git LFS Details

  • SHA256: e3fc46e697bf24cc96964c686665bbd66f228b73b16220959155e663b28a7757
  • Pointer size: 131 Bytes
  • Size of remote file: 351 kB
images/pexels-key-notez-1334945.jpg ADDED

Git LFS Details

  • SHA256: d7f3a6c5709d06aa37f86bed066ee91433b6426ab27f8edbfb261c9ba9fcced5
  • Pointer size: 131 Bytes
  • Size of remote file: 336 kB
images/pexels-oleg-magni-2764682.jpg ADDED

Git LFS Details

  • SHA256: 5a196dde3f658e447683f0e2ed84fe27868f95e9f0a2a88b4e448f832ec55ab9
  • Pointer size: 131 Bytes
  • Size of remote file: 798 kB
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
- mediapipe==0.8.9.1
2
- numpy==1.22.3
3
- opencv-python-headless==4.5.5.64
 
1
+ mediapipe==0.10.1
2
+ numpy==1.23.5
3
+ opencv-python-headless==4.8.0.74