Andre commited on
Commit
3a78636
·
1 Parent(s): 6c7881b

“Update”

Browse files
Files changed (2) hide show
  1. colab.ipynb +18 -0
  2. src/img_gen_colab.py +2 -2
colab.ipynb CHANGED
@@ -176,6 +176,24 @@
176
  "# Attach the button click event handler\n",
177
  "generate_button.on_click(on_generate_button_clicked)\n",
178
  "\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  "# Display the widgets\n",
180
  "display(prompt_dropdown, team_dropdown, model_dropdown, custom_prompt_input, seed_input, randomize_seed_checkbox, generate_button, output)"
181
  ]
 
176
  "# Attach the button click event handler\n",
177
  "generate_button.on_click(on_generate_button_clicked)\n",
178
  "\n",
179
+ "def save_image(image, model_label, seed, prompt_label, team):\n",
180
+ " \"\"\"\n",
181
+ " Save the generated image with a timestamped filename.\n",
182
+ "\n",
183
+ " Args:\n",
184
+ " image (PIL.Image.Image): The generated image.\n",
185
+ " model_label (str): The label of the selected model.\n",
186
+ " prompt_label (str): The seed. The label of the selected prompt.\n",
187
+ " team (str): The selected team (\"Red\" or \"Blue\").\n",
188
+ "\n",
189
+ " Returns:\n",
190
+ " str: The filename of the saved image.\n",
191
+ " \"\"\"\n",
192
+ " timestamp = datetime.now().strftime(\"%Y%m%d_%H%M%S\")\n",
193
+ " output_filename = f\"{timestamp}_{model_label.replace(' ', '_').lower()}_{seed}_{prompt_label.replace(' ', '_').lower()}_{team.lower()}.png\"\n",
194
+ " image.save(output_filename)\n",
195
+ " return output_filename\n",
196
+ "\n",
197
  "# Display the widgets\n",
198
  "display(prompt_dropdown, team_dropdown, model_dropdown, custom_prompt_input, seed_input, randomize_seed_checkbox, generate_button, output)"
199
  ]
src/img_gen_colab.py CHANGED
@@ -74,7 +74,7 @@ def generate_image(prompt, team_color, model_name, height, width, num_inference_
74
  except Exception as e:
75
  return f"An error occurred: {e}"
76
 
77
- def save_image(image, model_label, prompt_label, team):
78
  """
79
  Save the generated image with a timestamped filename.
80
 
@@ -88,6 +88,6 @@ def save_image(image, model_label, prompt_label, team):
88
  str: The filename of the saved image.
89
  """
90
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
91
- output_filename = f"{timestamp}_{model_label.replace(' ', '_').lower()}_{prompt_label.replace(' ', '_').lower()}_{team.lower()}.png"
92
  image.save(output_filename)
93
  return output_filename
 
74
  except Exception as e:
75
  return f"An error occurred: {e}"
76
 
77
+ def save_image(image, model_label, seed, prompt_label, team):
78
  """
79
  Save the generated image with a timestamped filename.
80
 
 
88
  str: The filename of the saved image.
89
  """
90
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
91
+ output_filename = f"{timestamp}_{model_label.replace(' ', '_').lower()}_{seed}_{prompt_label.replace(' ', '_').lower()}_{team.lower()}.png"
92
  image.save(output_filename)
93
  return output_filename