justina commited on
Commit
faf8968
·
1 Parent(s): 1af7499
Files changed (3) hide show
  1. app.py +25 -0
  2. model.pkl +3 -0
  3. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+ learn = load_learner('model.pkl')
5
+
6
+ searches = ['formal','casual','athletic']
7
+ searches = sorted(searches) # need to be sorted because that's the order the predictions will be outputed
8
+ values = [i for i in range(0,len(searches))]
9
+ class_dict = dict(zip(searches,values))
10
+
11
+ def classify(im):
12
+ classication,_,probs = learn.predict(im)
13
+ confidences = {label: float(probs[i]) for i, label in enumerate(class_dict)}
14
+ return confidences
15
+
16
+ intf = gr.Interface(fn=classify, inputs='image', outputs='label',
17
+ examples= [
18
+ ["https://www.datocms-assets.com/39109/1637755546-monochrome.jpg"],
19
+ ["https://live.staticflickr.com/4227/34761005741_917633fbb7.jpg"],
20
+ ["https://cdn.cliqueinc.com/posts/290845/classic-outfits-290845-1639432804292-main.1200x0c.jpg"],
21
+ ["https://www.refinery29.com/images/9193658.jpg"],
22
+ ["https://i.pinimg.com/736x/ac/ce/3a/acce3a1aea6aff8550c1c70a5b629394--sporty-clothes-nike-clothes.jpg"],
23
+ ],
24
+ title = 'Outfit Type Classifier')
25
+ intf.launch()
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:63ddbc594c37613da85e5272b3069a8a56af2426e70c04a3e2495ddaf276dfce
3
+ size 46953241
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ fastai==2.7.7