omega commited on
Commit
f4be4b8
·
1 Parent(s): 7f54b01
Files changed (5) hide show
  1. app.py +30 -0
  2. export.pkl +3 -0
  3. herobrine minecraft.jpg +0 -0
  4. requirements.txt +2 -0
  5. steve minecraft.jpg +0 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+
3
+ learn = load_learner('export.pkl')
4
+
5
+ # searches = 'steve minecraft','herobrine minecraft'
6
+
7
+ def sanity_check():
8
+ for o in searches:
9
+ category,_,probs = learn.predict(PILImage.create(f'{o}.jpg'))
10
+ print(f"This is a: {category}.")
11
+ print(f"Probability it's a {category}: {probs[0]:.4f}")
12
+
13
+ # sanity_check()
14
+
15
+ labels = learn.dls.vocab
16
+
17
+ def predict(img):
18
+ img = PILImage.create(img)
19
+ pred, pred_idx, probs = learn.predict(img)
20
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
21
+
22
+ import gradio as gr
23
+
24
+ gr.Interface(
25
+ fn=predict,
26
+ inputs=gr.inputs.Image(shape=(512, 512)),
27
+ examples = [ 'steve minecraft.jpg', 'herobrine minecraft.jpg' ],
28
+ interpertation='default',
29
+ outputs=gr.outputs.Label(num_top_classes=3)
30
+ ).launch(share=True)
export.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:82f97f5ce3b14b71570a3a73c1fa1d1918842ac83acd1b59b9059773a1590def
3
+ size 46967693
herobrine minecraft.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ scikit-image
steve minecraft.jpg ADDED