Spaces:
Runtime error
Runtime error
rajeshradhakrishnan
commited on
Commit
·
95f7fa9
1
Parent(s):
6c171ea
Update for malaylam news classifier
Browse files- app.py +21 -6
- class_names.txt +4 -0
- packages.txt +0 -0
- requirements.txt +2 -0
app.py
CHANGED
@@ -1,11 +1,26 @@
|
|
1 |
-
|
2 |
|
3 |
|
4 |
-
|
5 |
-
return "Hello " + name
|
6 |
|
7 |
|
8 |
-
# We instantiate the Textbox class
|
9 |
-
textbox = gr.Textbox(label="Type your name here:", placeholder="Rajesh Radhakrishnan", lines=2)
|
10 |
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from huggingface_hub import from_pretrained_fastai
|
2 |
|
3 |
|
4 |
+
LABELS = Path('class_names.txt').read_text().splitlines()
|
|
|
5 |
|
6 |
|
|
|
|
|
7 |
|
8 |
+
def predict(im):
|
9 |
+
learner = from_pretrained_fastai("rajeshradhakrishnan/ml-news-classify-fastai")
|
10 |
+
|
11 |
+
probabilities = learner.predict(sentences)
|
12 |
+
|
13 |
+
values, indices = torch.topk(probabilities, 5)
|
14 |
+
|
15 |
+
return {LABELS[i]: v.item() for i, v in zip(indices, values)}
|
16 |
+
|
17 |
+
interface = gr.Interface(
|
18 |
+
predict,
|
19 |
+
inputs="newsheadlines",
|
20 |
+
outputs='label',
|
21 |
+
theme="huggingface",
|
22 |
+
title="Sketch Recognition",
|
23 |
+
description="Malayalam News Classifier? Input a few malayalam news headlines and verify whether the model categorized it apporpirately!",
|
24 |
+
article = "<p style='text-align: center'>Malayalam News Classifier | Demo Model</p>",
|
25 |
+
live=True)
|
26 |
+
interface.launch(debug=True)
|
class_names.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
business
|
2 |
+
entertainment
|
3 |
+
sports
|
4 |
+
technology
|
packages.txt
ADDED
File without changes
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
huggingface_hub[fastai]
|
2 |
+
ohmeow-blurr
|