ruslanmv commited on
Commit
783cba8
·
verified ·
1 Parent(s): 3de03d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -2
app.py CHANGED
@@ -99,7 +99,7 @@ def load_model(model_key):
99
  model_load_status[model_key] = "Failed" # Update load status on error
100
  return f"Error loading model '{model_key}': {e}"
101
 
102
- @spaces.GPU(duration=120)
103
  def generate_image(model, prompt, seed=-1):
104
 
105
  generator = torch.Generator(device="cuda" if torch.cuda.is_available() else "cpu")
@@ -138,7 +138,54 @@ def gradio_load_model(selected_model):
138
  return load_model(selected_model)
139
 
140
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  with gr.Blocks(
143
  css="""
144
  .container {
@@ -184,7 +231,7 @@ with gr.Blocks(
184
 
185
  if __name__ == "__main__":
186
  interface.launch(debug=True)
187
-
188
 
189
  '''
190
  with gr.Blocks(
 
99
  model_load_status[model_key] = "Failed" # Update load status on error
100
  return f"Error loading model '{model_key}': {e}"
101
 
102
+ @spaces.GPU(duration=180)
103
  def generate_image(model, prompt, seed=-1):
104
 
105
  generator = torch.Generator(device="cuda" if torch.cuda.is_available() else "cpu")
 
138
  return load_model(selected_model)
139
 
140
 
141
+ with gr.Blocks(
142
+ css="""
143
+ .container {
144
+ max-width: 800px;
145
+ margin: auto;
146
+ padding: 20px;
147
+ background-color: #f8f8f8;
148
+ border-radius: 10px;
149
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
150
+ }
151
+ """
152
+ ) as interface:
153
+ with gr.Tab("Image Generator"):
154
+ with gr.Column():
155
+ gr.Markdown("# Text-to-Image Generator")
156
+ model_dropdown = gr.Dropdown(choices=list(models.keys()), label="Select Model")
157
+ prompt_textbox = gr.Textbox(label="Enter Text Prompt")
158
+ seed_slider = gr.Slider(minimum=-1, maximum=1000, step=1, value=-1, label="Random Seed (-1 for random)")
159
+ generate_button = gr.Button("Generate Image")
160
+ output_image = gr.Image(label="Generated Image")
161
+ runtime_info_textbox = gr.Textbox(label="Runtime Information", lines=2, interactive=False)
162
 
163
+ # Add example prompts at the bottom
164
+ gr.Markdown("### Example Prompts")
165
+ examples = gr.Examples(
166
+ examples=[
167
+ [list(models.keys())[0], "Sexy Woman", "sample2.png"],
168
+ [list(models.keys())[2], "Sexy girl", "sample3.png"],
169
+ [list(models.keys())[1], "Future City", "sample1.png"]
170
+ ],
171
+ inputs=[model_dropdown, prompt_textbox, output_image],
172
+ )
173
+
174
+ generate_button.click(gradio_generate, inputs=[model_dropdown, prompt_textbox, seed_slider], outputs=[output_image, runtime_info_textbox])
175
+
176
+ with gr.Tab("Model Information"):
177
+ for model_key, model_info in models.items():
178
+ gr.Markdown(f"## {model_key}")
179
+ gr.Markdown(model_info["description"])
180
+
181
+ gr.Markdown("""---
182
+ **Credits**: Created by Ruslan Magana Vsevolodovna. For more information, visit [https://ruslanmv.com/](https://ruslanmv.com/).""")
183
+
184
+ if __name__ == "__main__":
185
+ interface.launch(debug=True)
186
+
187
+
188
+ '''
189
  with gr.Blocks(
190
  css="""
191
  .container {
 
231
 
232
  if __name__ == "__main__":
233
  interface.launch(debug=True)
234
+ '''
235
 
236
  '''
237
  with gr.Blocks(