import gradio as gr dictionary = { 'a playful man': "A young man in his mid-20s to early 30s, Has a playful and energetic demeanor, with a big smile always on his face, Has a lean and athletic build, Has messy, yet stylish hair that is always styled in a way that makes it look like he just got out of bed, Has a playful twinkle in his eye, and a hint of mischief in his expression, Wears casual, comfortable clothing that is both stylish and practical,Often seen with a bag or backpack, as if he's always ready for an adventure" } def chatgpt(query): try: output = dictionary[query] except: output = "Please try: https://chat.openai.com" return output def generateimage1(query): try: output = dictionary[query] except: output = "Please try: https://chat.openai.com" return output def generateimage2(query): try: output = dictionary[query] except: output = "Please try: https://chat.openai.com" return output with gr.Blocks() as demo: gr.Markdown("Ask ChatGPT to generate detailed descriptbions.") with gr.Row(): inpprompt = gr.Dropdown(["a playful man", "a trusing woman", "a boy who is bullied"]) outprompt = gr.Textbox() btn = gr.Button("Generate mode detailed description.") btn.click(fn=chatgpt, inputs=inpprompt, outputs=outprompt) gr.Markdown("Ask **Stable Diffusion** to generate images.") with gr.Row(): out1image = gr.Image() out2image = gr.Image() with gr.Row(): btn1 = gr.Button("Generate image with origial prompt.") btn2 = gr.Button("Generate image with ChatGPT's prompt.") btn.click(fn=generateimage1, inputs=inpprompt, outputs=out1image) btn.click(fn=generateimage2, inputs=outprompt, outputs=out2image) demo.launch()