File size: 655 Bytes
2a4d57a
5c97177
80d7f37
2a4d57a
26ac2ac
 
6ad695c
2a4d57a
6ad695c
 
c5462b9
6ad695c
c5462b9
 
 
2a4d57a
6ad695c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from fastai.text.all import *
import gradio as gr
from huggingface_hub import from_pretrained_fastai

repo_id = "mahernto/imdbmodel"
learner = from_pretrained_fastai(repo_id)

def predict(text):
    pred,pred_idx,probs = learner.predict(text)
    if (pred == "0"):
        return "Negative"
    elif (pred == "1"):
        return "Positive"
    else:
        return "Error"

gr.Interface(fn=predict, inputs=gr.Textbox(lines=4, placeholder="Write your film review..."), outputs="text",examples=["An outstanding film with powerful performances and a moving story. A must-watch.","Terrible acting and a weak script. Not worth watching."]).launch(share=False)