Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -105,23 +105,23 @@ def predict(prompt, guidance, steps, seed=1231231):
|
|
105 |
if nsfw_content_detected:
|
106 |
nsfw=gr.Button("🕹️NSFW🎨", scale=1)
|
107 |
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
|
126 |
return results.images[0] if len(results.images) > 0 else None
|
127 |
|
|
|
105 |
if nsfw_content_detected:
|
106 |
nsfw=gr.Button("🕹️NSFW🎨", scale=1)
|
107 |
|
108 |
+
try:
|
109 |
+
central = pytz.timezone('US/Central')
|
110 |
+
safe_date_time = datetime.datetime.now().strftime("%Y%m%d")
|
111 |
+
replaced_prompt = prompt.replace(" ", "_").replace("\n", "_")
|
112 |
+
safe_prompt = "".join(x for x in replaced_prompt if x.isalnum() or x == "_")[:90]
|
113 |
+
filename = f"{safe_date_time}_{safe_prompt}.png"
|
114 |
+
|
115 |
+
# Save the image
|
116 |
+
if len(results.images) > 0:
|
117 |
+
image_path = os.path.join("", filename) # Specify your directory
|
118 |
+
results.images[0].save(image_path)
|
119 |
+
print(f"#Image saved as {image_path}")
|
120 |
+
encoded_image = encode_image(image)
|
121 |
+
html_link = f'<a href="data:image/png;base64,{encoded_image}" download="{filename}">Download Image</a>'
|
122 |
+
#gr.Markdown(html_link)
|
123 |
+
except:
|
124 |
+
return results.images[0]
|
125 |
|
126 |
return results.images[0] if len(results.images) > 0 else None
|
127 |
|