outfit-type / app.py
justina's picture
add files
faf8968
from fastai.vision.all import *
import gradio as gr
learn = load_learner('model.pkl')
searches = ['formal','casual','athletic']
searches = sorted(searches) # need to be sorted because that's the order the predictions will be outputed
values = [i for i in range(0,len(searches))]
class_dict = dict(zip(searches,values))
def classify(im):
classication,_,probs = learn.predict(im)
confidences = {label: float(probs[i]) for i, label in enumerate(class_dict)}
return confidences
intf = gr.Interface(fn=classify, inputs='image', outputs='label',
examples= [
["https://www.datocms-assets.com/39109/1637755546-monochrome.jpg"],
["https://live.staticflickr.com/4227/34761005741_917633fbb7.jpg"],
["https://cdn.cliqueinc.com/posts/290845/classic-outfits-290845-1639432804292-main.1200x0c.jpg"],
["https://www.refinery29.com/images/9193658.jpg"],
["https://i.pinimg.com/736x/ac/ce/3a/acce3a1aea6aff8550c1c70a5b629394--sporty-clothes-nike-clothes.jpg"],
],
title = 'Outfit Type Classifier')
intf.launch()