|
Hugging Face's logo |
|
Hugging Face |
|
Search models, datasets, users... |
|
Models |
|
Datasets |
|
Spaces |
|
Docs |
|
Solutions |
|
Pricing |
|
|
|
|
|
|
|
Spaces: |
|
|
|
runaksh |
|
/ |
|
Symptom-2-disease_Text_Classification |
|
|
|
|
|
like |
|
0 |
|
|
|
Logs |
|
App |
|
Files |
|
Community |
|
Settings |
|
Symptom-2-disease_Text_Classification |
|
/ |
|
app.py |
|
runaksh's picture |
|
runaksh |
|
Update app.py |
|
7450a2c |
|
about 2 months ago |
|
raw |
|
history |
|
blame |
|
edit |
|
delete |
|
No virus |
|
1.33 kB |
|
|
|
"""gradio_deploy.ipynb |
|
Automatically generated by Colaboratory. |
|
""" |
|
import os |
|
import gradio |
|
from PIL import Image |
|
from timeit import default_timer as timer |
|
from tensorflow import keras |
|
import torch |
|
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline |
|
import numpy as np |
|
|
|
loaded_model = AutoModelForSequenceClassification.from_pretrained("runaksh/financial_sentiment_distilBERT") |
|
loaded_tokenizer = AutoTokenizer.from_pretrained("runaksh/financial_sentiment_distilBERT") |
|
|
|
|
|
def predict(sample, validate=True): |
|
classifier = pipeline("text-classification", model=loaded_model, tokenizer=loaded_tokenizer) |
|
pred = classifier(sample)[0]['label'] |
|
return pred |
|
|
|
title = "Financial Sentiment Classification" |
|
description = "Enter the news" |
|
|
|
|
|
|
|
|
|
in_prompt = gradio.components.Textbox(lines=2, label='Enter the News') |
|
|
|
|
|
out_response = gradio.components.Textbox(label='Sentiment') |
|
|
|
|
|
iface = gradio.Interface(fn=predict, |
|
inputs = in_prompt, |
|
outputs = out_response, |
|
title=title, |
|
description=description |
|
) |
|
|
|
iface.launch(debug = True) |
|
|