Spaces:
Build error
Build error
| # 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=["."]) | |