| from transformers import pipeline |
| import gradio as gr |
| import joblib |
| model__ = joblib.load('model.joblib') |
| tokenizer__ = joblib.load('tokenizer.joblib') |
| from transformers import pipeline |
| import gradio as gr |
|
|
| pipe = pipeline("text2text-generation", model="abdwahdia/bart-base-joker") |
|
|
| |
| 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) |
|
|
| |
| 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() |