Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Ini adalah contoh aplikasi Gradio yang menggunakan model dari Hugging Face | |
| # Model ini akan diunduh saat aplikasi Gradio pertama kali dijalankan | |
| classifier = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english") | |
| def analyze_sentiment(text): | |
| result = classifier(text)[0] | |
| return f"Sentiment: {result['label']} (Score: {result['score']:.2f})" | |
| iface = gr.Interface( | |
| fn=analyze_sentiment, | |
| inputs="text", | |
| outputs="text", | |
| title="Sentiment Analyzer" | |
| ) | |
| if __name__ == "__main__": | |
| # PENTING: Gunakan share=True untuk mendapatkan public URL | |
| iface.launch(share=True, debug=True) | |
| if __name__ == "__main__": | |
| iface.launch(share=True) # Tambahkan argumen ini |