Spaces:
Runtime error
Runtime error
File size: 885 Bytes
4943816 868dbd1 95f7fa9 6c171ea 95f7fa9 6c171ea 95f7fa9 868dbd1 95f7fa9 868dbd1 95f7fa9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
from pathlib import Path
import torch
import gradio as gr
from huggingface_hub import from_pretrained_fastai
LABELS = Path('class_names.txt').read_text().splitlines()
def predict(im):
learner = from_pretrained_fastai("rajeshradhakrishnan/ml-news-classify-fastai")
probabilities = learner.predict(im)
values, indices = torch.topk(probabilities, 5)
return {LABELS[i]: v.item() for i, v in zip(indices, values)}
interface = gr.Interface(
predict,
inputs="newsheadlines",
outputs='label',
theme="huggingface",
title="Malayalam News Classifier",
description="Try to classify news in മലയാളം? Input a few malayalam news headlines and verify whether the model categorized it apporpirately!",
article = "<p style='text-align: center'>Malayalam News Classifier | Demo Model</p>",
live=True)
interface.launch(debug=True)
|