Spaces:
Running
Running
Update
Browse files- .gitattributes +1 -0
- .gitignore +0 -1
- README.md +1 -1
- app.py +4 -31
- images/pexels-george-dolgikh-giftpunditscom-1310522.jpg +3 -0
- images/pexels-key-notez-1334945.jpg +3 -0
- images/pexels-oleg-magni-2764682.jpg +3 -0
- requirements.txt +3 -3
.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.
|
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 =
|
68 |
-
examples = [[path
|
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'
|
85 |
examples=examples,
|
86 |
title=TITLE,
|
87 |
description=DESCRIPTION,
|
88 |
-
).launch(
|
|
|
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
|
images/pexels-key-notez-1334945.jpg
ADDED
Git LFS Details
|
images/pexels-oleg-magni-2764682.jpg
ADDED
Git LFS Details
|
requirements.txt
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
mediapipe==0.
|
2 |
-
numpy==1.
|
3 |
-
opencv-python-headless==4.
|
|
|
1 |
+
mediapipe==0.10.1
|
2 |
+
numpy==1.23.5
|
3 |
+
opencv-python-headless==4.8.0.74
|