Spaces:
Runtime error
Runtime error
Commit
·
301bce7
1
Parent(s):
f3f4f0a
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pathlib import Path
|
2 |
+
import gradio as gr
|
3 |
+
from huggingface_hub import from_pretrained_fastai
|
4 |
+
|
5 |
+
|
6 |
+
LABELS = Path('class_names.txt').read_text().splitlines()
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
def predict(news_headline):
|
11 |
+
learner = from_pretrained_fastai("rajeshradhakrishnan/ml-news-classify-fastai")
|
12 |
+
|
13 |
+
probabilities = learner.predict(news_headline)
|
14 |
+
|
15 |
+
return {LABELS[i]: probabilities[0]['probs'][i] for i in range(len(LABELS))}
|
16 |
+
|
17 |
+
interface = gr.Interface(
|
18 |
+
predict,
|
19 |
+
inputs="textbox",
|
20 |
+
outputs='label',
|
21 |
+
theme="huggingface",
|
22 |
+
title="Malayalam News Classifier",
|
23 |
+
description="Try to classify news in മലയാളം? Input a few malayalam news headlines and verify whether the model categorized it appropriately!",
|
24 |
+
article = "<p style='text-align: center'>Malayalam News Classifier | Demo Model</p>",
|
25 |
+
examples=[["ഓഹരി വിപണി തകരുമ്പോള് നിക്ഷേപം എങ്ങനെ സുരക്ഷിതമാക്കാം"], ["വാര്ണറുടെ ഒറ്റക്കയ്യന് ക്യാച്ചില് അമ്പരന്ന് ക്രിക്കറ്റ് ലോകം"]],
|
26 |
+
# live=True,
|
27 |
+
share=True)
|
28 |
+
interface.launch(debug=True)
|