Spaces:
Runtime error
Runtime error
Download app.py from SpawnedShoyo/testing-ai: direct link, hf CLI and curl.
- Browser
- Download file 517 Bytes
-
https://huggingface.co/spaces/SpawnedShoyo/testing-ai/resolve/main/app.py
- Command line
-
hf download hf://spaces/SpawnedShoyo/testing-ai/app.py
-
curl -L -o app.py https://huggingface.co/spaces/SpawnedShoyo/testing-ai/resolve/main/app.py
517 Bytes
| # Import necessary libraries | |
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the model using Transformers pipeline | |
| classifier = pipeline("sentiment-analysis") | |
| # Define the function to make predictions | |
| def predict_sentiment(text): | |
| result = classifier(text)[0] | |
| return f'Text: {text}\nSentiment: {result["label"]} with confidence {result["score"]}' | |
| # Create a Gradio interface | |
| iface = gr.Interface(fn=predict_sentiment, inputs="text", outputs="text") | |
| # Launch the Gradio interface | |
| iface.launch() |