File size: 968 Bytes
8261053 6fa2f2a e0d9991 8cde03d e0d9991 69717e0 e0d9991 657f408 69717e0 e0d9991 69717e0 e0d9991 69717e0 4e604eb 69717e0 |
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 |
# Title: Integrate Image Generation in custom Chatbots 🔥
# Author: Dr. Andreas Fischer
# Date: June 4th, 2024
#--------------------------------------------------
import gradio as gr
import os, shutil, time
from gradio_client import Client
client = Client("ByteDance/Hyper-SDXL-1Step-T2I")
id=0
def multimodalResponse(message,history):
global id
id=id+1
print(message)
result = client.predict(
num_images=1,
height=1024,
width=1024,
prompt=message,
seed=3413,
api_name="/process_image")
shutil.copy(result[0]['image'],os.getcwd())
os.rename('image.webp', 'image'+str(id)+'.webp')
return "Prompt '"+message+"': +"/image"+str(id)+".webp)"
bot=gr.Chatbot(
value=[[None,"I'm a simple image-generating chatbot. Please tell me what you would like to see."]],
render_markdown=True)
interface=gr.ChatInterface(multimodalResponse,chatbot=bot, multimodal=False)
interface.launch(allowed_paths=["."])
|