Skip to content

Commit

Permalink
Update app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
slyfox1186 authored Dec 16, 2024
1 parent ce45e22 commit d97cd55
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion AI/flux-image-creator/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ def sanitize_filename(prompt):
filename = prompt.strip()
filename = re.sub(r'[^\w\s-]', '', filename)
filename = re.sub(r'[-\s]+', '_', filename)
return filename

# Truncate the filename to a reasonable length (e.g., 100 characters)
# Add a hash of the full prompt to ensure uniqueness
if len(filename) > 100:
# Get first 90 characters and add hash of full prompt
prompt_hash = hex(hash(prompt))[-8:] # Last 8 chars of hash
filename = f"{filename[:90]}_{prompt_hash}"

return filename + ".png"

def generate_image(prompt, width, height, steps, guidance_scale=0.0, sequence_length=256, seed=-1, save_image=True):
try:
Expand Down

0 comments on commit d97cd55

Please sign in to comment.