HelloAI1 commited on
Commit
37aed4e
·
verified ·
1 Parent(s): f36681b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -52
app.py CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  import numpy as np
2
  import gradio as gr
3
  import requests
@@ -157,13 +162,13 @@ body {
157
  """
158
 
159
  with gr.Blocks(css=css) as demo:
160
- state = gr.State(value="Welcome Screen")
161
 
162
  def update_visibility(tab_state):
163
- return gr.Tabs.update(visible=(tab_state == "Main Generation Screen"))
164
 
165
  with gr.Tabs() as tabs:
166
- with gr.TabItem("Welcome Screen"):
167
  with gr.Row():
168
  logo = gr.Image(
169
  value="http://disneypixaraigenerator.com/wp-content/uploads/2023/12/cropped-android-chrome-512x512-1.png",
@@ -173,64 +178,34 @@ with gr.Blocks(css=css) as demo:
173
  )
174
 
175
  with gr.Row():
176
- title = gr.Markdown("<h1 style='text-align: center;'>Disney Pixar AI Generator</h1>", elem_id="title")
177
 
178
  with gr.Row():
179
  start_button = gr.Button("Get Started", variant='primary', elem_id="start-button")
180
 
181
- with gr.TabItem("Main Generation Screen"):
182
  with gr.Row():
183
- gr.Markdown("<h1 style='text-align: center;'>Create Your Disney Pixar AI Poster</h1>", elem_id="title")
184
 
185
- with gr.Row(elem_id="image-output-container"):
186
  image_output = gr.Image(
187
  value="https://cdn-uploads.huggingface.co/production/uploads/noauth/XWJyh9DhMGXrzyRJk7SfP.png",
188
  label="Generated Image",
189
  elem_id="image-output"
190
  )
191
 
192
- with gr.Row(elem_id="settings"):
193
- with gr.Column(scale=1, min_width=300, elem_classes="setting-group"):
194
- prompt = gr.Textbox(
195
- "space warrior, beautiful, female, ultrarealistic, soft lighting, 8k",
196
- placeholder="Enter your prompt here...",
197
- show_label=False,
198
- lines=3,
199
- elem_id="prompt-input"
200
- )
201
- negative_prompt = gr.Textbox(
202
- placeholder="Enter negative prompts (optional)...",
203
- show_label=False,
204
- lines=3,
205
- value="3d, cartoon, anime, (deformed eyes, nose, ears, nose), bad anatomy, ugly"
206
- )
207
- text_button = gr.Button("Generate", variant='primary', elem_id="generate")
208
-
209
- with gr.Column(scale=1, min_width=300, elem_classes="setting-group"):
210
- model = gr.Dropdown(
211
- interactive=True,
212
- value="sd_xl_base_1.0.safetensors [be9edd61]",
213
- show_label=True,
214
- label="Model",
215
- choices=prodia_client.list_models()
216
- )
217
- sampler = gr.Dropdown(
218
- value="DPM++ 2M Karras",
219
- show_label=True,
220
- label="Sampling Method",
221
- choices=prodia_client.list_samplers()
222
- )
223
- steps = gr.Slider(label="Sampling Steps", minimum=1, maximum=25, value=20, step=1)
224
-
225
- with gr.Column(scale=1, min_width=300, elem_classes="setting-group"):
226
- width = gr.Slider(label="Width", minimum=512, maximum=1536, value=1024, step=8)
227
- height = gr.Slider(label="Height", minimum=512, maximum=1536, value=1024, step=8)
228
- cfg_scale = gr.Slider(label="CFG Scale", minimum=1, maximum=20, value=7, step=1)
229
- seed = gr.Number(label="Seed", value=-1)
230
-
231
- text_button.click(flip_text, inputs=[prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed], outputs=image_output)
232
- start_button.click(fn=lambda: "Main Generation Screen", inputs=None, outputs=state)
233
- state.change(fn=update_visibility, inputs=state, outputs=tabs)
234
-
235
- # Launch the Gradio app
236
- demo.launch(max_threads=128)
 
1
+ It seems like there's an issue with the code where `State` object is being used incorrectly. The error indicates that the `State` object doesn't have a `change` attribute.
2
+
3
+ Let's correct this by using the appropriate method to update the state. Here's the modified code:
4
+
5
+ ```python
6
  import numpy as np
7
  import gradio as gr
8
  import requests
 
162
  """
163
 
164
  with gr.Blocks(css=css) as demo:
165
+ state = gr.InterfaceState(value="Welcome Screen")
166
 
167
  def update_visibility(tab_state):
168
+ return tab_state == "Main Generation Screen"
169
 
170
  with gr.Tabs() as tabs:
171
+ with gr.Tab("Welcome Screen"):
172
  with gr.Row():
173
  logo = gr.Image(
174
  value="http://disneypixaraigenerator.com/wp-content/uploads/2023/12/cropped-android-chrome-512x512-1.png",
 
178
  )
179
 
180
  with gr.Row():
181
+ title = gr.Textbox("<h1 style='text-align: center;'>Disney Pixar AI Generator</h1>", elem_id="title")
182
 
183
  with gr.Row():
184
  start_button = gr.Button("Get Started", variant='primary', elem_id="start-button")
185
 
186
+ with gr.Tab("Main Generation Screen"):
187
  with gr.Row():
188
+ gr.Textbox("<h1 style='text-align: center;'>Create Your Disney Pixar AI Poster</h1>", elem_id="title")
189
 
190
+ with gr.Row():
191
  image_output = gr.Image(
192
  value="https://cdn-uploads.huggingface.co/production/uploads/noauth/XWJyh9DhMGXrzyRJk7SfP.png",
193
  label="Generated Image",
194
  elem_id="image-output"
195
  )
196
 
197
+ with gr.Row():
198
+ prompt = gr.Textbox(
199
+ "space warrior, beautiful, female, ultrarealistic, soft lighting, 8k",
200
+ placeholder="Enter your prompt here...",
201
+ show_label=False,
202
+ lines=3,
203
+ elem_id="prompt-input"
204
+ )
205
+ negative_prompt = gr.Textbox(
206
+ placeholder="Enter negative prompts (optional)...",
207
+ show_label=False,
208
+ lines=3,
209
+ value="3d, cartoon, anime, (deformed eyes, nose, ears, nose), bad anatomy, ugly"
210
+ )
211
+