Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,9 +15,21 @@ DESCRIPTION = """
|
|
15 |
# DALL•E 3 XL v2
|
16 |
"""
|
17 |
|
18 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
unique_name = str(uuid.uuid4()) + ".png"
|
20 |
img.save(unique_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
return unique_name
|
22 |
|
23 |
def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
@@ -83,8 +95,12 @@ def generate(
|
|
83 |
output_type="pil",
|
84 |
).images
|
85 |
image_paths = [save_image(img) for img in images]
|
|
|
|
|
86 |
print(image_paths)
|
87 |
-
return image_paths, seed
|
|
|
|
|
88 |
|
89 |
#examples = [
|
90 |
# "neon holography crystal cat",
|
|
|
15 |
# DALL•E 3 XL v2
|
16 |
"""
|
17 |
|
18 |
+
def create_download_link(filename):
|
19 |
+
with open(filename, "rb") as file:
|
20 |
+
encoded_string = base64.b64encode(file.read()).decode('utf-8')
|
21 |
+
download_link = f'<a href="data:image/png;base64,{encoded_string}" download="{filename}">Download Image</a>'
|
22 |
+
return download_link
|
23 |
+
|
24 |
+
def save_image(img, prompt):
|
25 |
unique_name = str(uuid.uuid4()) + ".png"
|
26 |
img.save(unique_name)
|
27 |
+
|
28 |
+
# save with promp to save prompt as image file name
|
29 |
+
filename = f"{prompt}.png"
|
30 |
+
img.save(filename)
|
31 |
+
return filename
|
32 |
+
|
33 |
return unique_name
|
34 |
|
35 |
def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
|
|
95 |
output_type="pil",
|
96 |
).images
|
97 |
image_paths = [save_image(img) for img in images]
|
98 |
+
download_links = [create_download_link(path) for path in image_paths]
|
99 |
+
|
100 |
print(image_paths)
|
101 |
+
#return image_paths, seed
|
102 |
+
return image_paths, seed, download_links
|
103 |
+
|
104 |
|
105 |
#examples = [
|
106 |
# "neon holography crystal cat",
|