shogi880 commited on
Commit
ca8adc9
1 Parent(s): 4c30446

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -21
app.py CHANGED
@@ -14,39 +14,30 @@ def chatgpt(query):
14
  return output
15
 
16
  def generateimage1(query):
17
- try:
18
- output = dictionary[query]
19
- except:
20
- output = "Please try: https://chat.openai.com"
21
- return output
22
 
23
- def generateimage2(query):
24
- try:
25
- output = dictionary[query]
26
- except:
27
- output = "Please try: https://chat.openai.com"
28
- return output
29
 
30
  with gr.Blocks() as demo:
31
  gr.Markdown("Ask **ChatGPT** to generate detailed descriptbions.")
32
  gr.Markdown("Example: Act as a professional character designer. Please generate prompts include detail appearance descriptions that related to the personality. Here's your first question: 'a gentle man':")
 
33
  with gr.Row():
34
  inpprompt = gr.Dropdown(list(dictionary.keys()))
35
  outprompt = gr.Textbox()
36
- btn = gr.Button("Generate mode detailed description.")
37
- btn.click(fn=chatgpt, inputs=inpprompt, outputs=outprompt)
38
 
39
-
40
- gr.Markdown("Ask **Stable Diffusion** to generate images.")
41
  with gr.Row():
42
  out1image = gr.Image()
43
  out2image = gr.Image()
44
- with gr.Row():
45
- btn1 = gr.Button("Generate image with origial prompt.")
46
- btn2 = gr.Button("Generate image with ChatGPT's prompt.")
47
-
48
- btn1.click(fn=generateimage1, inputs=inpprompt, outputs=out1image)
49
- btn2.click(fn=generateimage2, inputs=outprompt, outputs=out2image)
50
 
51
 
52
  demo.launch()
 
14
  return output
15
 
16
  def generateimage1(query):
17
+ image = query.replace(' ', '-') + '.png'
18
+ return image
 
 
 
19
 
20
+ def generateimage1(query):
21
+ image = query.replace(' ', '-') + '-chatgpt.png'
22
+ return image
 
 
 
23
 
24
  with gr.Blocks() as demo:
25
  gr.Markdown("Ask **ChatGPT** to generate detailed descriptbions.")
26
  gr.Markdown("Example: Act as a professional character designer. Please generate prompts include detail appearance descriptions that related to the personality. Here's your first question: 'a gentle man':")
27
+ gr.Markdown("Then ask **Stable Diffusion** to generate images based on ChatGPT prompts.")
28
  with gr.Row():
29
  inpprompt = gr.Dropdown(list(dictionary.keys()))
30
  outprompt = gr.Textbox()
 
 
31
 
 
 
32
  with gr.Row():
33
  out1image = gr.Image()
34
  out2image = gr.Image()
35
+
36
+ btn = gr.Button("Generate mode detailed description.")
37
+ btn.click(fn=chatgpt, inputs=inpprompt, outputs=outprompt)
38
+
39
+ btn.click(fn=generateimage1, inputs=inpprompt, outputs=out1image)
40
+ btn.click(fn=generateimage2, inputs=outprompt, outputs=out2image)
41
 
42
 
43
  demo.launch()