Spaces:
Sleeping
Sleeping
Download app.py from Simrankodwani-2003/Text_classifiers: direct link, hf CLI and curl.
- Browser
- Download file 981 Bytes
-
https://huggingface.co/spaces/Simrankodwani-2003/Text_classifiers/resolve/main/app.py
- Command line
-
hf download hf://spaces/Simrankodwani-2003/Text_classifiers/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Simrankodwani-2003/Text_classifiers/resolve/main/app.py
981 Bytes
| # -*- coding: utf-8 -*- | |
| """Text_classifiers.ipynb | |
| Automatically generated by Colab. | |
| Original file is located at | |
| https://colab.research.google.com/drive/12UdfdxBHN2JLxsSOPPzTp7JkXOXxArJn | |
| """ | |
| from transformers import pipeline | |
| #!pip install transformers | |
| classifier=pipeline("text-classification",model="distilbert/distilbert-base-uncased-finetuned-sst-2-english") | |
| classifier("I absolutely love this new phone! The camera quality is amazing") | |
| classifier("this is so boring movie") | |
| import gradio as gr | |
| from transformers import pipeline | |
| classifier=pipeline("text-classification",model="distilbert/distilbert-base-uncased-finetuned-sst-2-english") | |
| def predict_sentiments(text): | |
| return classifier(text)[0] | |
| gr.Interface(fn=predict_sentiments, | |
| inputs=[gr.Textbox(label="Insert Prompt here", lines=5)], | |
| outputs=[gr.Textbox(label="outputs sentiments", lines=3)], | |
| title="My App" | |
| ).launch(share=True) | |
| #!pip install gradio | |