Spaces:
Running
Running
Update
Browse files- .gitattributes +1 -0
- .gitignore +0 -1
- README.md +1 -1
- app.py +4 -34
- 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: indigo
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 3.
|
| 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 =
|
| 95 |
-
examples = [[path
|
| 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',
|
| 117 |
examples=examples,
|
| 118 |
title=TITLE,
|
| 119 |
description=DESCRIPTION,
|
| 120 |
-
).launch(
|
|
|
|
| 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
|
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
|