Spaces:
Runtime error
Runtime error
from transformers import pipeline | |
import gradio as gr | |
# importer joblib | |
import joblib | |
model=joblib.load('model.joblib') | |
tokenizer=joblib.load("tokenizer.joblib") | |
def blagueur(prompt): | |
inputs = tokenizer(prompt, return_tensors="pt", truncation=True, padding="max_length", max_length=128) | |
outputs = model.generate( | |
input_ids=inputs["input_ids"], | |
attention_mask=inputs["attention_mask"], | |
max_length=64, | |
num_beams=5, | |
do_sample=True, | |
temperature=0.9 | |
) | |
return tokenizer.decode(outputs[0], skip_special_tokens=True) | |
# Configuration de l'interface Gradio | |
demo = gr.Interface( | |
fn=blagueur, | |
inputs=gr.Textbox(lines=2, placeholder="Demandez-moi une blague..."), | |
outputs="text", | |
title="Chatbot Comique", | |
description="Un chatbot qui raconte des blagues. Demandez-lui une blague et il vous fera rire!", | |
examples=[ | |
["Raconte-moi une blague"], | |
["Dis-moi une blague sur les animaux"], | |
["Blague sur les informaticiens"] | |
], | |
theme='shivi/calm_seafoam' | |
) | |
demo.launch() |