Update
Browse files- .gitattributes +1 -0
- .gitignore +0 -1
- README.md +1 -1
- app.py +6 -36
- images/pexels-allan-mas-5368927.jpg +3 -0
- images/pexels-allan-mas-5368976.jpg +3 -0
- images/pexels-ana-bregantin-1930364.jpg +3 -0
- images/pexels-anastasiya-gepp-4456142.jpg +3 -0
- images/pexels-anastasiya-gepp-4456152.jpg +3 -0
- images/pexels-august-de-richelieu-4427813.jpg +3 -0
- images/pexels-cottonbro-5770445.jpg +3 -0
- images/pexels-cottonbro-5770708.jpg +3 -0
- images/pexels-cottonbro-6800242.jpg +3 -0
- images/pexels-dmitriy-ganin-9167601.jpg +3 -0
- images/pexels-haste-leart-v-690598.jpg +3 -0
- images/pexels-jake-_sulli_-swoyer-5835863.jpg +3 -0
- images/pexels-jasmine-carter-812258.jpg +3 -0
- images/pexels-jo-kassis-5567802.jpg +3 -0
- images/pexels-kaichieh-chan-917510.jpg +3 -0
- images/pexels-luis-gallegos-alvarez-1164975.jpg +3 -0
- images/pexels-lukas-rodriguez-3492736.jpg +3 -0
- images/pexels-martin-lopez-2240771.jpg +3 -0
- images/pexels-mehmet-turgut-kirkgoz-11596703.jpg +3 -0
- images/pexels-nataliya-vaitkevich-4943547.jpg +3 -0
- images/pexels-satoshi-hirayama-1325837.jpg +3 -0
- images/pexels-victoria-borodinova-7909580.jpg +3 -0
- images/pexels-yan-krukov-5792907.jpg +3 -0
- images/pexels-yogendra-singh-1701195.jpg +3 -0
- images/pexels-лиза-медведева-8574605.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: blue
|
5 |
colorTo: gray
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 3.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
|
|
4 |
colorFrom: blue
|
5 |
colorTo: gray
|
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_pose = mp.solutions.pose
|
|
26 |
TITLE = 'MediaPipe Human Pose Estimation'
|
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 = ['002.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(image: np.ndarray, model_complexity: int, enable_segmentation: bool,
|
49 |
min_detection_confidence: float, background_color: str) -> np.ndarray:
|
@@ -82,10 +53,9 @@ def run(image: np.ndarray, model_complexity: int, enable_segmentation: bool,
|
|
82 |
model_complexities = list(range(3))
|
83 |
background_colors = ['white', 'black', 'green']
|
84 |
|
85 |
-
image_paths =
|
86 |
-
examples = [[
|
87 |
-
|
88 |
-
] for path in image_paths]
|
89 |
|
90 |
gr.Interface(
|
91 |
fn=run,
|
@@ -95,7 +65,7 @@ gr.Interface(
|
|
95 |
choices=model_complexities,
|
96 |
type='index',
|
97 |
value=model_complexities[1]),
|
98 |
-
gr.Checkbox(
|
99 |
gr.Slider(label='Minimum Detection Confidence',
|
100 |
minimum=0,
|
101 |
maximum=1,
|
@@ -106,8 +76,8 @@ gr.Interface(
|
|
106 |
type='value',
|
107 |
value=background_colors[0]),
|
108 |
],
|
109 |
-
outputs=gr.Image(label='Output',
|
110 |
examples=examples,
|
111 |
title=TITLE,
|
112 |
description=DESCRIPTION,
|
113 |
-
).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 Human Pose Estimation'
|
16 |
DESCRIPTION = 'https://google.github.io/mediapipe/'
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
def run(image: np.ndarray, model_complexity: int, enable_segmentation: bool,
|
20 |
min_detection_confidence: float, background_color: str) -> np.ndarray:
|
|
|
53 |
model_complexities = list(range(3))
|
54 |
background_colors = ['white', 'black', 'green']
|
55 |
|
56 |
+
image_paths = sorted(pathlib.Path('images').rglob('*.jpg'))
|
57 |
+
examples = [[path, model_complexities[1], True, 0.5, background_colors[0]]
|
58 |
+
for path in image_paths]
|
|
|
59 |
|
60 |
gr.Interface(
|
61 |
fn=run,
|
|
|
65 |
choices=model_complexities,
|
66 |
type='index',
|
67 |
value=model_complexities[1]),
|
68 |
+
gr.Checkbox(label='Enable Segmentation', value=True),
|
69 |
gr.Slider(label='Minimum Detection Confidence',
|
70 |
minimum=0,
|
71 |
maximum=1,
|
|
|
76 |
type='value',
|
77 |
value=background_colors[0]),
|
78 |
],
|
79 |
+
outputs=gr.Image(label='Output', height=500),
|
80 |
examples=examples,
|
81 |
title=TITLE,
|
82 |
description=DESCRIPTION,
|
83 |
+
).queue().launch()
|
images/pexels-allan-mas-5368927.jpg
ADDED
Git LFS Details
|
images/pexels-allan-mas-5368976.jpg
ADDED
Git LFS Details
|
images/pexels-ana-bregantin-1930364.jpg
ADDED
Git LFS Details
|
images/pexels-anastasiya-gepp-4456142.jpg
ADDED
Git LFS Details
|
images/pexels-anastasiya-gepp-4456152.jpg
ADDED
Git LFS Details
|
images/pexels-august-de-richelieu-4427813.jpg
ADDED
Git LFS Details
|
images/pexels-cottonbro-5770445.jpg
ADDED
Git LFS Details
|
images/pexels-cottonbro-5770708.jpg
ADDED
Git LFS Details
|
images/pexels-cottonbro-6800242.jpg
ADDED
Git LFS Details
|
images/pexels-dmitriy-ganin-9167601.jpg
ADDED
Git LFS Details
|
images/pexels-haste-leart-v-690598.jpg
ADDED
Git LFS Details
|
images/pexels-jake-_sulli_-swoyer-5835863.jpg
ADDED
Git LFS Details
|
images/pexels-jasmine-carter-812258.jpg
ADDED
Git LFS Details
|
images/pexels-jo-kassis-5567802.jpg
ADDED
Git LFS Details
|
images/pexels-kaichieh-chan-917510.jpg
ADDED
Git LFS Details
|
images/pexels-luis-gallegos-alvarez-1164975.jpg
ADDED
Git LFS Details
|
images/pexels-lukas-rodriguez-3492736.jpg
ADDED
Git LFS Details
|
images/pexels-martin-lopez-2240771.jpg
ADDED
Git LFS Details
|
images/pexels-mehmet-turgut-kirkgoz-11596703.jpg
ADDED
Git LFS Details
|
images/pexels-nataliya-vaitkevich-4943547.jpg
ADDED
Git LFS Details
|
images/pexels-satoshi-hirayama-1325837.jpg
ADDED
Git LFS Details
|
images/pexels-victoria-borodinova-7909580.jpg
ADDED
Git LFS Details
|
images/pexels-yan-krukov-5792907.jpg
ADDED
Git LFS Details
|
images/pexels-yogendra-singh-1701195.jpg
ADDED
Git LFS Details
|
images/pexels-лиза-медведева-8574605.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
|