Spaces:
Running
Running
peterbonnesoeur
commited on
Commit
Β·
9369100
1
Parent(s):
2ae0a81
First commit
Browse files- README.md +1 -1
- apolloscape.jpeg +0 -0
- app.py +39 -0
- bill.png +0 -0
- billie.png +0 -0
- dalmatian.jpg +0 -0
- elon.png +0 -0
- requirements.txt +9 -0
- test.jpg +0 -0
- vehicles.jpg +0 -0
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
title: Pose_demo
|
3 |
-
emoji:
|
4 |
colorFrom: blue
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
|
|
1 |
---
|
2 |
title: Pose_demo
|
3 |
+
emoji: π§βπ»
|
4 |
colorFrom: blue
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
apolloscape.jpeg
ADDED
app.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from PIL import Image
|
2 |
+
import torch
|
3 |
+
import gradio as gr
|
4 |
+
import openpifpaf
|
5 |
+
import numpy as np
|
6 |
+
|
7 |
+
|
8 |
+
predictor_animal = openpifpaf.Predictor(checkpoint='shufflenetv2k30-animalpose')
|
9 |
+
predictor_whole_body = openpifpaf.Predictor(checkpoint='shufflenetv2k16-wholebody')
|
10 |
+
predictor_vehicle = openpifpaf.Predictor(checkpoint='shufflenetv2k16-apollo-24')
|
11 |
+
|
12 |
+
|
13 |
+
def inference(img, ver):
|
14 |
+
|
15 |
+
if ver == 'whole-body':
|
16 |
+
predictor = predictor_whole_body
|
17 |
+
elif ver == 'vehicles':
|
18 |
+
predictor = predictor_vehicle
|
19 |
+
elif ver == 'animal':
|
20 |
+
predictor = predictor_animal
|
21 |
+
else:
|
22 |
+
raise ValueError('invalid version')
|
23 |
+
|
24 |
+
predictions, gt_anns, image_meta = predictor.pil_image(img)
|
25 |
+
annotation_painter = openpifpaf.show.AnnotationPainter()
|
26 |
+
with openpifpaf.show.image_canvas(img, fig_file = "test.jpg") as ax:
|
27 |
+
annotation_painter.annotations(ax, predictions)
|
28 |
+
|
29 |
+
out = Image.open("test.jpg")
|
30 |
+
return out
|
31 |
+
|
32 |
+
|
33 |
+
title = "Openpifpaf"
|
34 |
+
description = "Gradio demo for openpifpaf. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please use a cropped portrait picture for best results similar to the examples below"
|
35 |
+
article = "<p style='text-align: center'><a href='https://github.com/openpifpaf/openpifpaf' target='_blank'>Github Repo Openpifpaf</a> | <a href='https://github.com/peterbonnesoeur' target='_blank'>Github Repo peterbonnesoeur</a></p>"
|
36 |
+
|
37 |
+
examples=[ ['bill.png', 'whole-body'], ['vehicles.jpg', 'vehicles'], ['apolloscape.jpeg', 'vehicles'], ['dalmatian.jpg', 'animal'], ['elon.png','whole-body'], ['billie.png','whole-body']]
|
38 |
+
gr.Interface(inference, [gr.inputs.Image(type="pil"),gr.inputs.Radio(['pose','whole-body', 'vehicles', 'animal'], type="value", default='whole-body', label='version')
|
39 |
+
], gr.outputs.Image(type="pil"),title=title,description=description,article=article,enable_queue=True,examples=examples).launch()
|
bill.png
ADDED
billie.png
ADDED
dalmatian.jpg
ADDED
elon.png
ADDED
requirements.txt
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
openpifpaf
|
3 |
+
Pillow
|
4 |
+
gdown
|
5 |
+
numpy
|
6 |
+
scipy
|
7 |
+
cmake
|
8 |
+
openpifpaf
|
9 |
+
opencv-python-headless
|
test.jpg
ADDED
vehicles.jpg
ADDED