LucyintheSky commited on
Commit
6badb61
1 Parent(s): 885e258

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -1,15 +1,26 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
 
4
  crop_pipe = pipeline("image-classification", model="LucyintheSky/pose-estimation-crop-uncrop")
 
 
5
 
6
  def classify(img):
 
7
  crop = crop_pipe(img)
8
- result = crop[0]['label'] + ' (' + str(int(float(crop[0]['score']) * 100)) + '%)'
 
 
 
 
 
 
 
9
  return result
10
 
11
  iface = gr.Interface(fn=classify,
12
  inputs=gr.Image(label='Image', type='filepath'),
13
- outputs=gr.Textbox(label='Output'),
14
  theme=gr.themes.Base(primary_hue=gr.themes.colors.pink, secondary_hue=gr.themes.colors.gray, neutral_hue=gr.themes.colors.slate, font=["avenir"]))
15
  iface.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Initialize pipelines
5
  crop_pipe = pipeline("image-classification", model="LucyintheSky/pose-estimation-crop-uncrop")
6
+ pose_pipe = pipeline("image-classification", model="LucyintheSky/pose-estimation-front-side-back")
7
+ name_pipe = pipeline("image-classification", model="LucyintheSky/model-prediction")
8
 
9
  def classify(img):
10
+ # Classify image
11
  crop = crop_pipe(img)
12
+ pose = pose_pipe(img)
13
+ name = name_pipe(img)
14
+
15
+ # Format results
16
+ result = crop[0]['label'] + ' (' + str(int(float(crop[0]['score']) * 100)) + '%)\n'
17
+ result += pose[0]['label'] + ' (' + str(int(float(pose[0]['score']) * 100)) + '%)\n'
18
+ result += name[0]['label'] + ' (' + str(int(float(name[0]['score']) * 100)) + '%)'
19
+
20
  return result
21
 
22
  iface = gr.Interface(fn=classify,
23
  inputs=gr.Image(label='Image', type='filepath'),
24
+ outputs=gr.Textbox(label='Classification'),
25
  theme=gr.themes.Base(primary_hue=gr.themes.colors.pink, secondary_hue=gr.themes.colors.gray, neutral_hue=gr.themes.colors.slate, font=["avenir"]))
26
  iface.launch()