Spaces:
Sleeping
Sleeping
File size: 1,151 Bytes
0c0938d db72d10 0c0938d aa5b273 0c0938d | 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 34 35 36 37 38 39 | from transformers import pipeline
import gradio as gr
import joblib
blaguer = joblib.load('model.joblib')
tokblague = joblib.load('tokenizer.joblib')
# pipe = pipeline("text2text-generation", model="abdwahdia/bart-base-joker")
# Fonction
def blagueur(prompt):
inputs = tokblague(prompt, return_tensors="pt", truncation=True, padding="max_length", max_length=128)
outputs = blaguer.generate(
input_ids=inputs["input_ids"],
attention_mask=inputs["attention_mask"],
max_length=64,
num_beams=5,
do_sample=True,
temperature=0.9
)
return tokblague.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() |