Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline | |
import spaces | |
# Charger le pipeline de classification des sentiments | |
pipe = pipeline("text-generation", model="deepseek-ai/deepseek-llm-7b-base")@spaces.GPU | |
def analyze_sentiment(text): | |
# Analyser le sentiment du texte | |
result = pipe(text) | |
for result in results: | |
label = result['label'] | |
score = result['score'] | |
sentiments.append(f"Sentiment: {label}, Score: {score:.2f}") | |
return "\n".join(sentiments) | |
# Créer l'interface Gradio | |
interface = gr.Interface( | |
fn=pipe | |
inputs=gr.inputs.Textbox(lines=5, placeholder="Entrez votre texte ici..."), | |
outputs="text", | |
title="Analyse des Sentiments", | |
description="Entrez un texte pour analyser son sentiment (positif, négatif ou neutre)." | |
) | |
# Lancer l'interface dans un Space Hugging Face | |
if __name__ == "__main__": | |
interface.launch() | |