rajeshradhakrishnan commited on
Commit
95f7fa9
1 Parent(s): 6c171ea

Update for malaylam news classifier

Browse files
Files changed (4) hide show
  1. app.py +21 -6
  2. class_names.txt +4 -0
  3. packages.txt +0 -0
  4. requirements.txt +2 -0
app.py CHANGED
@@ -1,11 +1,26 @@
1
- import gradio as gr
2
 
3
 
4
- def greet(name):
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
- gr.Interface(fn=greet, inputs=textbox, outputs="text").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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