LucyintheSky's picture
Update app.py
6ed6efc
raw
history blame contribute delete
No virus
1.29 kB
import gradio as gr
from transformers import pipeline
# Initialize pipelines
crop_pipe = pipeline("image-classification", model="LucyintheSky/pose-estimation-crop-uncrop")
pose_pipe = pipeline("image-classification", model="LucyintheSky/pose-estimation-front-side-back")
name_pipe = pipeline("image-classification", model="LucyintheSky/model-prediction")
def classify(img):
# Classify image
crop = crop_pipe(img)
pose = pose_pipe(img)
name = name_pipe(img)
# Format results
result = crop[0]['label'] + ' (' + str(int(float(crop[0]['score']) * 100)) + '%)\n'
result += pose[0]['label'] + ' (' + str(int(float(pose[0]['score']) * 100)) + '%)\n'
result += name[0]['label'] + ' (' + str(int(float(name[0]['score']) * 100)) + '%)'
return result
iface = gr.Interface(fn=classify,
title='Product Photo Classifier',
inputs=gr.Image(label='Image', type='filepath'),
outputs=gr.Textbox(label='Classification'),
examples=[['./images/1.jpg'],['./images/2.jpg'],['./images/3.jpg']],
theme=gr.themes.Base(primary_hue=gr.themes.colors.pink, secondary_hue=gr.themes.colors.gray, neutral_hue=gr.themes.colors.slate, font=["avenir"]))
iface.launch()