finkrishna commited on
Commit
ba18e46
1 Parent(s): 7d7eb79

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -1,12 +1,9 @@
 
 
 
 
 
 
 
1
  import gradio as gr
2
-
3
- description = "Story generation with GPT-2"
4
- title = "Generate your own story"
5
- examples = [["Adventurer is approached by a mysterious stranger in the tavern for a new quest."]]
6
-
7
- interface = gr.Interface.load("huggingface/pranavpsv/gpt2-genre-story-generator",
8
- description=description,
9
- examples=examples
10
- )
11
-
12
- interface.launch()
 
1
+ from fastai.vision.all import *
2
+ learn = load_learner('export.pkl')
3
+ labels = learn.dls.vocab
4
+ def predict(img):
5
+ img = PILImage.create(img)
6
+ pred,pred_idx,probs = learn.predict(img)
7
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
8
  import gradio as gr
9
+ gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)