Spaces:
Running
Running
File size: 1,189 Bytes
faf8968 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
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()
|