hysts HF staff commited on
Commit
e3a9731
1 Parent(s): a5c1f85
.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: indigo
6
  sdk: gradio
7
- sdk_version: 3.19.1
8
  app_file: app.py
9
  pinned: false
10
  ---
 
4
  colorFrom: yellow
5
  colorTo: indigo
6
  sdk: gradio
7
+ sdk_version: 3.36.1
8
  app_file: app.py
9
  pinned: false
10
  ---
app.py CHANGED
@@ -2,20 +2,9 @@
2
 
3
  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
19
  import mediapipe as mp
20
  import numpy as np
21
 
@@ -26,24 +15,6 @@ mp_face_mesh = mp.solutions.face_mesh
26
  TITLE = 'MediaPipe Face Mesh'
27
  DESCRIPTION = 'https://google.github.io/mediapipe/'
28
 
29
- HF_TOKEN = os.getenv('HF_TOKEN')
30
-
31
-
32
- def load_sample_images() -> list[pathlib.Path]:
33
- image_dir = pathlib.Path('images')
34
- if not image_dir.exists():
35
- image_dir.mkdir()
36
- dataset_repo = 'hysts/input-images'
37
- filenames = ['001.tar', '005.tar']
38
- for name in filenames:
39
- path = huggingface_hub.hf_hub_download(dataset_repo,
40
- name,
41
- repo_type='dataset',
42
- use_auth_token=HF_TOKEN)
43
- with tarfile.open(path) as f:
44
- f.extractall(image_dir.as_posix())
45
- return sorted(image_dir.rglob('*.jpg'))
46
-
47
 
48
  def run(
49
  image: np.ndarray,
@@ -91,9 +62,8 @@ def run(
91
  return res[:, :, ::-1]
92
 
93
 
94
- image_paths = load_sample_images()
95
- examples = [[path.as_posix(), 5, 0.5, True, True, True]
96
- for path in image_paths]
97
 
98
  gr.Interface(
99
  fn=run,
@@ -113,8 +83,8 @@ gr.Interface(
113
  gr.Checkbox(label='Show Contours', value=True),
114
  gr.Checkbox(label='Show Irises', value=True),
115
  ],
116
- outputs=gr.Image(label='Output', type='numpy'),
117
  examples=examples,
118
  title=TITLE,
119
  description=DESCRIPTION,
120
- ).launch(show_api=False)
 
2
 
3
  from __future__ import annotations
4
 
 
5
  import pathlib
 
 
 
 
 
 
 
 
 
6
 
7
  import gradio as gr
 
8
  import mediapipe as mp
9
  import numpy as np
10
 
 
15
  TITLE = 'MediaPipe Face Mesh'
16
  DESCRIPTION = 'https://google.github.io/mediapipe/'
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  def run(
20
  image: np.ndarray,
 
62
  return res[:, :, ::-1]
63
 
64
 
65
+ image_paths = sorted(pathlib.Path('images').rglob('*.jpg'))
66
+ examples = [[path, 5, 0.5, True, True, True] for path in image_paths]
 
67
 
68
  gr.Interface(
69
  fn=run,
 
83
  gr.Checkbox(label='Show Contours', value=True),
84
  gr.Checkbox(label='Show Irises', value=True),
85
  ],
86
+ outputs=gr.Image(label='Output', height=500),
87
  examples=examples,
88
  title=TITLE,
89
  description=DESCRIPTION,
90
+ ).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