tombetthauser commited on
Commit
940a33d
β€’
1 Parent(s): c8dc4cf

Update with finished gallery label parser

Browse files
Files changed (1) hide show
  1. app.py +17 -3
app.py CHANGED
@@ -219,13 +219,27 @@ def image_prompt(prompt, guidance, steps, seed, height, width, negative_prompt="
219
  print(f"is_prompt_clean: {is_clean}")
220
  print("-------------------------------------------------------")
221
 
222
- trimmed_prompt = prompt.replace("<", "").replace(">", "").replace("ahx-beta-", "").replace("ahx-model-", "")
223
- # trimmed_prompt_array = trimmed_prompt.split(" ")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
 
225
  if is_clean:
226
  return (
227
  pipe(prompt=prompt, guidance_scale=guidance, num_inference_steps=steps, generator=generator, height=height, width=width, negative_prompt=negative_prompt).images[0],
228
- f"prompt: '{prompt}', seed = {int(seed)},\nheight: {height}px, width: {width}px,\nguidance: {guidance}, steps: {steps}, negative prompt: {negative_prompt}\n\n\n\"{trimmed_prompt}\" | ahx-{seed}.png"
229
  )
230
  else:
231
  return (
 
219
  print(f"is_prompt_clean: {is_clean}")
220
  print("-------------------------------------------------------")
221
 
222
+ input_prompt = prompt.replace(">", "").replace("<", "")
223
+ input_prompt = input_prompt.split(" ")
224
+
225
+ tokens = []
226
+ prompt_words = []
227
+
228
+ for word in input_prompt:
229
+ if "ahx" in word:
230
+ tokens.append(word.replace("ahx-beta-", "").replace("ahx-model-", ""))
231
+ else:
232
+ prompt_words.append(word)
233
+
234
+ joined_prompt_text = f"\"{' '.join(prompt_words)}\""
235
+ file_name = f"ahx-{'-'.join(tokens)}-{seed}.png"
236
+
237
+ gallery_label = f"{joined_prompt_text} | {file_name}"
238
 
239
  if is_clean:
240
  return (
241
  pipe(prompt=prompt, guidance_scale=guidance, num_inference_steps=steps, generator=generator, height=height, width=width, negative_prompt=negative_prompt).images[0],
242
+ f"{gallery_label}\n\nprompt: '{prompt}', seed = {int(seed)},\nheight: {height}px, width: {width}px,\nguidance: {guidance}, steps: {steps}, negative prompt: {negative_prompt}"
243
  )
244
  else:
245
  return (