Roei Zavida commited on
Commit
41e6c0d
·
unverified ·
1 Parent(s): 7ea0397

Refactor image display settings in app.py by adding CSS for image size control and updating the result image component to include a CSS class for styling.

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import base64
2
  import io
3
  import random
4
- import time
5
 
6
  import gradio as gr
7
  import openai
@@ -84,6 +83,13 @@ css = """
84
  margin: 0 auto;
85
  max-width: 640px;
86
  }
 
 
 
 
 
 
 
87
  """
88
 
89
  examples = [
@@ -152,7 +158,9 @@ with gr.Blocks(css=css, title="OpenAI Image Generator") as demo:
152
  "1024x1024", # size
153
  "standard", # quality
154
  "vivid", # style
155
- ]
 
 
156
  )
157
 
158
  with gr.Row():
@@ -181,7 +189,11 @@ with gr.Blocks(css=css, title="OpenAI Image Generator") as demo:
181
  )
182
  run_button = gr.Button("Run", scale=0, variant="primary")
183
 
184
- result = gr.Image(label="Result", show_label=False)
 
 
 
 
185
  gr.Examples(examples=examples, inputs=[prompt])
186
 
187
  # Load settings from browser storage
 
1
  import base64
2
  import io
3
  import random
 
4
 
5
  import gradio as gr
6
  import openai
 
83
  margin: 0 auto;
84
  max-width: 640px;
85
  }
86
+
87
+ /* Control image size */
88
+ .generated-image {
89
+ max-height: 512px;
90
+ width: auto;
91
+ object-fit: contain;
92
+ }
93
  """
94
 
95
  examples = [
 
158
  "1024x1024", # size
159
  "standard", # quality
160
  "vivid", # style
161
+ ],
162
+ storage_key="openai_image_generator_settings",
163
+ secret="77f22b9e8474262759b2bc23760b76af",
164
  )
165
 
166
  with gr.Row():
 
189
  )
190
  run_button = gr.Button("Run", scale=0, variant="primary")
191
 
192
+ result = gr.Image(
193
+ label="Result",
194
+ show_label=False,
195
+ elem_classes=["generated-image"], # Add the CSS class
196
+ )
197
  gr.Examples(examples=examples, inputs=[prompt])
198
 
199
  # Load settings from browser storage