awacke1 commited on
Commit
ec71404
1 Parent(s): cd68ed3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -12
app.py CHANGED
@@ -106,11 +106,6 @@ def predict(prompt, guidance, steps, seed=1231231):
106
  if nsfw_content_detected:
107
  nsfw=gr.Button("🕹️NSFW🎨", scale=1)
108
 
109
- # Generate file name
110
- #date_str = datetime.datetime.now().strftime("%Y%m%d")
111
- #safe_prompt = prompt.replace(" ", "_")[:50] # Truncate long prompts
112
- #filename = f"{date_str}_{safe_prompt}.png"
113
-
114
  central = pytz.timezone('US/Central')
115
  safe_date_time = datetime.datetime.now().strftime("%Y%m%d")
116
  replaced_prompt = prompt.replace(" ", "_").replace("\n", "_")
@@ -123,8 +118,6 @@ def predict(prompt, guidance, steps, seed=1231231):
123
  image_path = os.path.join("", filename) # Specify your directory
124
  results.images[0].save(image_path)
125
  print(f"#Image saved as {image_path}")
126
- #filename = safe_filename(prompt)
127
- #image.save(filename)
128
  encoded_image = encode_image(image)
129
  html_link = f'<a href="data:image/png;base64,{encoded_image}" download="{filename}">Download Image</a>'
130
  gr.Markdown(html_link)
@@ -161,7 +154,7 @@ with gr.Blocks(css=css) as demo:
161
  # Image Result from last prompt
162
  image = gr.Image(type="filepath")
163
 
164
- # Gallery
165
  with gr.Row(variant="compact"):
166
  text = gr.Textbox(
167
  label="Image Sets",
@@ -169,12 +162,12 @@ with gr.Blocks(css=css) as demo:
169
  max_lines=1,
170
  placeholder="Enter your prompt",
171
  )
172
- btn = gr.Button("Generate image")
173
-
174
  gallery = gr.Gallery(
175
- label="Generated images", show_label=False, elem_id="gallery"
176
  )
177
-
 
178
  with gr.Accordion("Advanced options", open=False):
179
  guidance = gr.Slider(
180
  label="Guidance", minimum=0.0, maximum=5, value=0.3, step=0.001
@@ -183,6 +176,8 @@ with gr.Blocks(css=css) as demo:
183
  seed = gr.Slider(
184
  randomize=True, minimum=0, maximum=12013012031030, label="Seed", step=1
185
  )
 
 
186
  with gr.Accordion("Run with diffusers"):
187
  gr.Markdown(
188
  """## Running LCM-LoRAs it with `diffusers`
@@ -207,6 +202,7 @@ with gr.Blocks(css=css) as demo:
207
  """
208
  )
209
 
 
210
  inputs = [prompt, guidance, steps, seed]
211
  generate_bt.click(fn=predict, inputs=inputs, outputs=image, show_progress=False)
212
  btn.click(fake_gan, None, gallery)
 
106
  if nsfw_content_detected:
107
  nsfw=gr.Button("🕹️NSFW🎨", scale=1)
108
 
 
 
 
 
 
109
  central = pytz.timezone('US/Central')
110
  safe_date_time = datetime.datetime.now().strftime("%Y%m%d")
111
  replaced_prompt = prompt.replace(" ", "_").replace("\n", "_")
 
118
  image_path = os.path.join("", filename) # Specify your directory
119
  results.images[0].save(image_path)
120
  print(f"#Image saved as {image_path}")
 
 
121
  encoded_image = encode_image(image)
122
  html_link = f'<a href="data:image/png;base64,{encoded_image}" download="{filename}">Download Image</a>'
123
  gr.Markdown(html_link)
 
154
  # Image Result from last prompt
155
  image = gr.Image(type="filepath")
156
 
157
+ # Gallery of Generated Images with Image Names in Random Set to Download
158
  with gr.Row(variant="compact"):
159
  text = gr.Textbox(
160
  label="Image Sets",
 
162
  max_lines=1,
163
  placeholder="Enter your prompt",
164
  )
165
+ btn = gr.Button("Generate Gallery of Saved Images")
 
166
  gallery = gr.Gallery(
167
+ label="Generated Images", show_label=False, elem_id="gallery"
168
  )
169
+
170
+ # Advanced Generate Options
171
  with gr.Accordion("Advanced options", open=False):
172
  guidance = gr.Slider(
173
  label="Guidance", minimum=0.0, maximum=5, value=0.3, step=0.001
 
176
  seed = gr.Slider(
177
  randomize=True, minimum=0, maximum=12013012031030, label="Seed", step=1
178
  )
179
+
180
+ # Diffusers
181
  with gr.Accordion("Run with diffusers"):
182
  gr.Markdown(
183
  """## Running LCM-LoRAs it with `diffusers`
 
202
  """
203
  )
204
 
205
+ # Function IO Eventing and Controls
206
  inputs = [prompt, guidance, steps, seed]
207
  generate_bt.click(fn=predict, inputs=inputs, outputs=image, show_progress=False)
208
  btn.click(fake_gan, None, gallery)