51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
import gradio as gr
|
|
import random
|
|
import time
|
|
|
|
|
|
def add_text(history, text):
|
|
history = history + [(text, None)]
|
|
return history, gr.update(value="", interactive=False)
|
|
|
|
|
|
def add_file(history, file):
|
|
history = history + [(('./outputs/a.png',), ('./outputs/a.png', './outputs/a.png'))]
|
|
return history
|
|
|
|
|
|
def bot(history):
|
|
response = "**That's cool!**"
|
|
# history[-1][1] = ""
|
|
for character in response:
|
|
# history[-1][1] += character
|
|
# time.sleep(0.05)
|
|
yield history
|
|
|
|
|
|
with gr.Blocks() as demo:
|
|
chatbot = gr.Chatbot([], label='Fooocus', height=750)
|
|
|
|
with gr.Row():
|
|
with gr.Column(scale=0.85):
|
|
txt = gr.Textbox(
|
|
show_label=False,
|
|
placeholder="Type prompt here.",
|
|
container=False
|
|
)
|
|
with gr.Column(scale=0.15, min_width=0):
|
|
btn = gr.UploadButton("Generate", file_types=["image"])
|
|
|
|
with gr.Row():
|
|
gr.Checkbox(label='Advanced Setting', value=False, container=False)
|
|
|
|
txt_msg = txt.submit(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(
|
|
bot, chatbot, chatbot
|
|
)
|
|
txt_msg.then(lambda: gr.update(interactive=True), None, [txt], queue=False)
|
|
file_msg = btn.upload(add_file, [chatbot, btn], [chatbot], queue=False).then(
|
|
bot, chatbot, chatbot
|
|
)
|
|
|
|
demo.queue() # number size style quality seed
|
|
demo.launch()
|