Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -83,7 +83,6 @@ def predict(prompt, guidance, steps, seed=1231231):
|
|
| 83 |
if nsfw_content_detected:
|
| 84 |
nsfw=gr.Button("🕹️NSFW🎨", scale=1)
|
| 85 |
|
| 86 |
-
|
| 87 |
# Generate file name
|
| 88 |
date_str = datetime.datetime.now().strftime("%Y%m%d")
|
| 89 |
safe_prompt = prompt.replace(" ", "_")[:50] # Truncate long prompts
|
|
@@ -94,11 +93,17 @@ def predict(prompt, guidance, steps, seed=1231231):
|
|
| 94 |
image_path = os.path.join("", filename) # Specify your directory
|
| 95 |
results.images[0].save(image_path)
|
| 96 |
print(f"#Image saved as {image_path}")
|
| 97 |
-
|
| 98 |
-
return results.images[0] if len(results.images) > 0 else None
|
| 99 |
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
|
| 104 |
css = """
|
|
|
|
| 83 |
if nsfw_content_detected:
|
| 84 |
nsfw=gr.Button("🕹️NSFW🎨", scale=1)
|
| 85 |
|
|
|
|
| 86 |
# Generate file name
|
| 87 |
date_str = datetime.datetime.now().strftime("%Y%m%d")
|
| 88 |
safe_prompt = prompt.replace(" ", "_")[:50] # Truncate long prompts
|
|
|
|
| 93 |
image_path = os.path.join("", filename) # Specify your directory
|
| 94 |
results.images[0].save(image_path)
|
| 95 |
print(f"#Image saved as {image_path}")
|
|
|
|
|
|
|
| 96 |
|
| 97 |
+
# Create a download link
|
| 98 |
+
with open(image_path, "rb") as file:
|
| 99 |
+
btn = st.download_button(
|
| 100 |
+
label="Download 📥",
|
| 101 |
+
data=file,
|
| 102 |
+
file_name=filename,
|
| 103 |
+
mime="image/png"
|
| 104 |
+
)
|
| 105 |
+
|
| 106 |
+
return results.images[0] if len(results.images) > 0 else None
|
| 107 |
|
| 108 |
|
| 109 |
css = """
|