Commit
·
4cf4a9e
1
Parent(s):
61a75b7
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,25 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
import gradio as gr
|
3 |
|
4 |
+
model_checkpoint = "MuntasirHossain/distilbert-finetuned-ag-news"
|
5 |
|
6 |
+
model = pipeline("text-classification", model=model_checkpoint)
|
7 |
+
|
8 |
+
|
9 |
+
def predict(prompt):
|
10 |
+
completion = model(prompt)[0]["label"]
|
11 |
+
return completion
|
12 |
+
|
13 |
+
description = "This AI model is trained to classify news articles into four categories: World, Sports, Business and Science/Tech."
|
14 |
+
title = "Classify Your Articles"
|
15 |
+
theme = "peach"
|
16 |
+
examples=[["Global Retail Giants Gear Up for Record-Breaking Holiday Sales Season Amidst Supply Chain Challenges and Rising Consumer Demand."], ["Business"]]
|
17 |
+
|
18 |
+
gr.Interface(fn=predict,
|
19 |
+
inputs="textbox",
|
20 |
+
outputs="text",
|
21 |
+
title=title,
|
22 |
+
theme = theme,
|
23 |
+
description=description,
|
24 |
+
examples=examples,
|
25 |
+
).launch()
|