File size: 810 Bytes
aaa9850
 
 
588ff0c
aaa9850
a30b0ed
aaa9850
 
 
 
a19509f
 
aaa9850
 
 
 
 
 
 
 
62519b7
aaa9850
 
 
 
 
b7d4893
 
e4917a3
aaa9850
 
 
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
27
28
29
30
31
32
import gradio as gr
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
import numpy as np

model_name = "Bittar/outputs"
model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)

mapping = {
    0: 'negative',
    1: 'positive'
}

def predict(text):
    inputs = tokenizer(text, return_tensors="pt")

    outputs = model(**inputs)
    predictions = outputs.logits

    return mapping[predictions.argmax().item()]

iface = gr.Interface(
    fn=predict,
    inputs="text",
    outputs="text",
    layout="vertical",
    title="Movie feelings classifier",
    description="do u feel positive or negative about a movie? Write your review down and find out! (only works in english)"
)

iface.launch(share=True)