Add requirements
Browse files
app.py
CHANGED
|
@@ -1,9 +1,13 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
| 3 |
|
|
|
|
|
|
|
|
|
|
| 4 |
# Load the tokenizer and model
|
| 5 |
tokenizer = AutoTokenizer.from_pretrained('distilbert/distilbert-base-uncased', add_prefix_space=True)
|
| 6 |
-
model = AutoModelForSequenceClassification.from_pretrained(
|
|
|
|
| 7 |
|
| 8 |
# Create the pipeline
|
| 9 |
classifier = pipeline('text-classification', model=model, tokenizer=tokenizer)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
| 3 |
|
| 4 |
+
id2label = {0: "Negative", 1: "Positive"}
|
| 5 |
+
label2id = {"Negative":0, "Positive":1}
|
| 6 |
+
|
| 7 |
# Load the tokenizer and model
|
| 8 |
tokenizer = AutoTokenizer.from_pretrained('distilbert/distilbert-base-uncased', add_prefix_space=True)
|
| 9 |
+
model = AutoModelForSequenceClassification.from_pretrained(
|
| 10 |
+
model="AmirRghp/distilbert-base-uncasedimdb-text-classification", num_labels=2, id2label=id2label, label2id=label2id)
|
| 11 |
|
| 12 |
# Create the pipeline
|
| 13 |
classifier = pipeline('text-classification', model=model, tokenizer=tokenizer)
|