Spaces:
Sleeping
Sleeping
File size: 698 Bytes
4c3d645 a81ae9a 4c3d645 a81ae9a 4c3d645 a81ae9a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
from transformers import AutoModelForSequenceClassification
from transformers import AutoTokenizer
from transformers import pipeline
model_loader = AutoModelForSequenceClassification.from_pretrained("content/models")
tokenizer_loader = AutoTokenizer.from_pretrained("content/models")
model_loader.eval()
print("loaded")
classifier = pipeline("sentiment-analysis", model=model_loader, tokenizer=tokenizer_loader, device=0)
def greet(twitter):
pred = classifier(twitter)[0]
return "twitter is %s with score=%.4f" % (pred['label'], pred['score'])
if __name__ == '__main__':
interFace = gr.Interface(fn=greet, inputs="text", outputs="text")
interFace.launch()
|