heaversm commited on
Commit
5fa41d5
·
1 Parent(s): 1cd7e2c

remove options, add instructions, use dall-e-2 standard 512

Browse files
Files changed (1) hide show
  1. app.py +11 -15
app.py CHANGED
@@ -22,10 +22,10 @@ def generate_image(text, model, quality, size):
22
 
23
  response = client.images.generate(
24
  prompt=text,
25
- model=model,
26
- quality=quality,
27
- size=size,
28
- n=1,
29
  )
30
  except Exception as error:
31
  print(str(error))
@@ -35,20 +35,16 @@ def generate_image(text, model, quality, size):
35
 
36
 
37
  with gr.Blocks() as demo:
38
- gr.Markdown("# <center> OpenAI Image Generate API with Gradio </center>")
39
- with gr.Row(variant="panel"):
40
- model = gr.Dropdown(choices=["dall-e-2", "dall-e-3"], label="Model", value="dall-e-3")
41
- quality = gr.Dropdown(choices=["standard", "hd"], label="Quality", value="standard")
42
- size = gr.Dropdown(choices=["1024x1024", "1792x1024", "1024x1792"], label="Size",
43
- value="1024x1024")
44
-
45
- text = gr.Textbox(label="Input Text",
46
  placeholder="Enter your text and then click on the \"Image Generate\" button, "
47
  "or simply press the Enter key.")
48
- btn = gr.Button("Image Generate")
49
  output_image = gr.Image(label="Image Output")
50
 
51
- text.submit(fn=generate_image, inputs=[text, model, quality, size], outputs=output_image, api_name="generate_image")
52
- btn.click(fn=generate_image, inputs=[text, model, quality, size], outputs=output_image, api_name=False)
53
 
54
  demo.launch(share=True)
 
22
 
23
  response = client.images.generate(
24
  prompt=text,
25
+ model="dall-e-2", # dall-e-2 or dall-e-3
26
+ quality="standard", # standard or hd
27
+ size="512x512", # varies for dalle-2 and dalle-3, see https://openai.com/pricing for resolutions
28
+ n=1, # Number of images to generate
29
  )
30
  except Exception as error:
31
  print(str(error))
 
35
 
36
 
37
  with gr.Blocks() as demo:
38
+ gr.Markdown("# <center> Prompt de Resistance Image Generator</center>")
39
+ gr.Markdown("**Instructions**: Generate an image from the text prompt below, then click the download arrow from the top right of the image to save it.")
40
+
41
+ text = gr.Textbox(label="What do you want to create?",
 
 
 
 
42
  placeholder="Enter your text and then click on the \"Image Generate\" button, "
43
  "or simply press the Enter key.")
44
+ btn = gr.Button("Generate Image")
45
  output_image = gr.Image(label="Image Output")
46
 
47
+ text.submit(fn=generate_image, inputs=[text], outputs=output_image, api_name="generate_image")
48
+ btn.click(fn=generate_image, inputs=[text], outputs=output_image, api_name=False)
49
 
50
  demo.launch(share=True)