Spaces:
Running
Running
DarwinAnim8or
commited on
Commit
·
9e8dd8e
1
Parent(s):
a9e76be
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,3 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import TextClassificationPipeline, AutoTokenizer, AutoModelForSequenceClassification
|
3 |
|
4 |
-
|
5 |
-
model_name = "KoalaAI/Text-Moderation"
|
6 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
-
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
8 |
-
|
9 |
-
# Create a TextClassificationPipeline
|
10 |
-
pipe = TextClassificationPipeline(model=model, tokenizer=tokenizer)
|
11 |
-
|
12 |
-
# Define the classify_text function using the pipeline
|
13 |
-
def classify_text(text):
|
14 |
-
prediction = pipe(text)[0]
|
15 |
-
return prediction
|
16 |
-
|
17 |
-
# Create a Gradio interface
|
18 |
-
iface = gr.Interface(
|
19 |
-
fn=classify_text,
|
20 |
-
inputs=gr.components.Textbox(label="Enter text"),
|
21 |
-
outputs=gr.outputs.Label(num_top_classes=None), # Show all labels
|
22 |
-
)
|
23 |
-
|
24 |
-
# Launch the Gradio app
|
25 |
-
iface.launch()
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
+
gr.Interface.load("models/KoalaAI/Text-Moderation").launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|