Spaces:
Runtime error
Runtime error
File size: 910 Bytes
d46fa4f 62f2a72 cf4674b fa7e230 62f2a72 d81e561 e1021d2 cf4674b 62f2a72 e1021d2 1a67d0c 62f2a72 e1021d2 62f2a72 3db2cf3 62f2a72 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
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
@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()
|