Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,7 @@ from PIL import Image
|
|
| 7 |
import re
|
| 8 |
import base64
|
| 9 |
from io import BytesIO
|
|
|
|
| 10 |
|
| 11 |
try:
|
| 12 |
import intel_extension_for_pytorch as ipex
|
|
@@ -98,9 +99,16 @@ def predict(prompt, guidance, steps, seed=1231231):
|
|
| 98 |
nsfw=gr.Button("🕹️NSFW🎨", scale=1)
|
| 99 |
|
| 100 |
# Generate file name
|
| 101 |
-
date_str = datetime.datetime.now().strftime("%Y%m%d")
|
| 102 |
-
safe_prompt = prompt.replace(" ", "_")[:50] # Truncate long prompts
|
| 103 |
-
filename = f"{date_str}_{safe_prompt}.png"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
# Save the image
|
| 106 |
if len(results.images) > 0:
|
|
|
|
| 7 |
import re
|
| 8 |
import base64
|
| 9 |
from io import BytesIO
|
| 10 |
+
import pytz
|
| 11 |
|
| 12 |
try:
|
| 13 |
import intel_extension_for_pytorch as ipex
|
|
|
|
| 99 |
nsfw=gr.Button("🕹️NSFW🎨", scale=1)
|
| 100 |
|
| 101 |
# Generate file name
|
| 102 |
+
#date_str = datetime.datetime.now().strftime("%Y%m%d")
|
| 103 |
+
#safe_prompt = prompt.replace(" ", "_")[:50] # Truncate long prompts
|
| 104 |
+
#filename = f"{date_str}_{safe_prompt}.png"
|
| 105 |
+
|
| 106 |
+
central = pytz.timezone('US/Central')
|
| 107 |
+
safe_date_time = datetime.now(central).strftime("%m%d_%H%M")
|
| 108 |
+
replaced_prompt = prompt.replace(" ", "_").replace("\n", "_")
|
| 109 |
+
safe_prompt = "".join(x for x in replaced_prompt if x.isalnum() or x == "_")[:90]
|
| 110 |
+
filename = f{safe_date_time}_{safe_prompt}.{file_type}"
|
| 111 |
+
|
| 112 |
|
| 113 |
# Save the image
|
| 114 |
if len(results.images) > 0:
|