ml / client_demo.py
Jeff_
Initial commit: Add sentiment analysis demo with Gradio
63d0071 unverified
Raw History Blame Contribute Delete
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()