Spaces:
Runtime error
Runtime error
measmonysuon
commited on
Commit
•
b3fd847
1
Parent(s):
091515f
Update app.py
Browse files
app.py
CHANGED
@@ -121,7 +121,7 @@ def create_gradio_interface():
|
|
121 |
# Create other components
|
122 |
prompt_input = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...")
|
123 |
resolution_dropdown = gr.Dropdown(choices=list(resolutions.keys()), label="Resolution", value="1024x1024")
|
124 |
-
generate_button = gr.Button("Generate"
|
125 |
|
126 |
result_output = gr.Image(label="Generated Image", type="pil")
|
127 |
message_output = gr.Textbox(label="Result", placeholder="Results will be shown here", interactive=False)
|
@@ -132,15 +132,21 @@ def create_gradio_interface():
|
|
132 |
points_output
|
133 |
get_points_button
|
134 |
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
|
|
|
|
139 |
points = get_user_points(user_chat_id)
|
140 |
if points >= 5:
|
141 |
-
return gr.Button.update(visible=True)
|
142 |
else:
|
143 |
-
return gr.Button.update(visible=False)
|
|
|
|
|
|
|
|
|
144 |
|
145 |
# Set up interaction
|
146 |
generate_button.click(
|
@@ -150,7 +156,7 @@ def create_gradio_interface():
|
|
150 |
)
|
151 |
|
152 |
get_points_button.click(
|
153 |
-
fn=
|
154 |
inputs=[user_chat_id_input],
|
155 |
outputs=[points_output, generate_button]
|
156 |
)
|
|
|
121 |
# Create other components
|
122 |
prompt_input = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...")
|
123 |
resolution_dropdown = gr.Dropdown(choices=list(resolutions.keys()), label="Resolution", value="1024x1024")
|
124 |
+
generate_button = gr.Button("Generate")
|
125 |
|
126 |
result_output = gr.Image(label="Generated Image", type="pil")
|
127 |
message_output = gr.Textbox(label="Result", placeholder="Results will be shown here", interactive=False)
|
|
|
132 |
points_output
|
133 |
get_points_button
|
134 |
|
135 |
+
with gr.Row():
|
136 |
+
prompt_input
|
137 |
+
resolution_dropdown
|
138 |
+
generate_button
|
139 |
+
|
140 |
+
def update_points_and_generate_button(user_chat_id):
|
141 |
points = get_user_points(user_chat_id)
|
142 |
if points >= 5:
|
143 |
+
return points, gr.Button.update(visible=True)
|
144 |
else:
|
145 |
+
return points, gr.Button.update(visible=False)
|
146 |
+
|
147 |
+
def handle_get_points(user_chat_id):
|
148 |
+
points, button_state = update_points_and_generate_button(user_chat_id)
|
149 |
+
return points, button_state
|
150 |
|
151 |
# Set up interaction
|
152 |
generate_button.click(
|
|
|
156 |
)
|
157 |
|
158 |
get_points_button.click(
|
159 |
+
fn=handle_get_points,
|
160 |
inputs=[user_chat_id_input],
|
161 |
outputs=[points_output, generate_button]
|
162 |
)
|