Spaces:
Build error
Build error
Download client_demo.py from bertiekeller/ml: direct link, hf CLI and curl.
- Browser
- Download file 793 Bytes
-
https://huggingface.co/spaces/bertiekeller/ml/resolve/main/client_demo.py
- Command line
-
hf download hf://spaces/bertiekeller/ml/client_demo.py
-
curl -L -o client_demo.py https://huggingface.co/spaces/bertiekeller/ml/resolve/main/client_demo.py
793 Bytes
| from gradio_client import Client | |
| # Initialize client | |
| client = Client("http://127.0.0.1:7860") | |
| def test_sentiment_analysis(): | |
| # Test cases | |
| texts = [ | |
| "I love this product! It's amazing!", | |
| "This is terrible, I hate it.", | |
| "The weather is okay today." | |
| ] | |
| print("Testing Sentiment Analysis API...\n") | |
| for text in texts: | |
| # Make prediction | |
| result = client.predict(text, api_name="/predict") | |
| sentiment, confidence = result | |
| print(f"Text: {text}") | |
| print(f"Sentiment: {sentiment}") | |
| print(f"Confidence: {confidence:.4f}\n") | |
| if __name__ == "__main__": | |
| print("Make sure the Gradio app is running on http://127.0.0.1:7860") | |
| print("Starting client demo...\n") | |
| test_sentiment_analysis() |