Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,8 @@ import spaces
|
|
11 |
import torch
|
12 |
import glob
|
13 |
from datetime import datetime
|
|
|
|
|
14 |
|
15 |
from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler
|
16 |
|
@@ -38,6 +40,14 @@ def get_image_gallery():
|
|
38 |
image_files.sort(key=os.path.getmtime, reverse=True)
|
39 |
return image_files
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
MAX_SEED = np.iinfo(np.int32).max
|
42 |
|
43 |
if not torch.cuda.is_available():
|
@@ -93,14 +103,21 @@ def generate(
|
|
93 |
return image_paths, seed, download_links, get_image_gallery()
|
94 |
|
95 |
examples = [
|
96 |
-
"
|
97 |
-
|
98 |
-
"
|
99 |
-
|
100 |
-
"
|
101 |
-
|
102 |
-
"
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
]
|
105 |
|
106 |
css = '''
|
@@ -169,6 +186,7 @@ with gr.Blocks(css=css, theme="pseudolab/huggingface-korea-theme") as demo:
|
|
169 |
)
|
170 |
|
171 |
image_gallery = gr.Gallery(label="Generated Images", show_label=True, columns=4, height="auto")
|
|
|
172 |
|
173 |
gr.Examples(
|
174 |
examples=examples,
|
@@ -209,6 +227,12 @@ with gr.Blocks(css=css, theme="pseudolab/huggingface-korea-theme") as demo:
|
|
209 |
api_name="run",
|
210 |
)
|
211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
demo.load(fn=update_gallery, outputs=image_gallery)
|
213 |
|
214 |
if __name__ == "__main__":
|
|
|
11 |
import torch
|
12 |
import glob
|
13 |
from datetime import datetime
|
14 |
+
import zipfile
|
15 |
+
import io
|
16 |
|
17 |
from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler
|
18 |
|
|
|
40 |
image_files.sort(key=os.path.getmtime, reverse=True)
|
41 |
return image_files
|
42 |
|
43 |
+
def create_zip_archive():
|
44 |
+
image_files = get_image_gallery()
|
45 |
+
zip_buffer = io.BytesIO()
|
46 |
+
with zipfile.ZipFile(zip_buffer, 'w', zipfile.ZIP_DEFLATED) as zip_file:
|
47 |
+
for image_file in image_files:
|
48 |
+
zip_file.write(image_file)
|
49 |
+
return zip_buffer.getvalue()
|
50 |
+
|
51 |
MAX_SEED = np.iinfo(np.int32).max
|
52 |
|
53 |
if not torch.cuda.is_available():
|
|
|
103 |
return image_paths, seed, download_links, get_image_gallery()
|
104 |
|
105 |
examples = [
|
106 |
+
"A bustling cityscape at sunset, where sleek, translucent skyscrapers shimmer with holographic displays. Gentle AI-powered drones weave through the air, delivering packages and tending to floating gardens. In the foreground, a diverse group of humans and lifelike androids share a laugh at a streetside café, their animated conversation bringing warmth to the scene.",
|
107 |
+
|
108 |
+
"An awe-inspiring orbital habitat, a massive ring structure gleaming against the starry backdrop of space. Its curved interior surface is a lush, verdant landscape dotted with futuristic buildings. AI-managed ecosystems flourish, and robotic caretakers tend to exotic alien plants in crystal-domed conservatories. Earth hangs like a jewel in the distance, visible through the habitat's transparent sections.",
|
109 |
+
|
110 |
+
"A cozy, high-tech living room bathed in soft, ambient light. An elderly woman sits in a hover-chair, her eyes twinkling with joy as she interacts with a holographic display. Surrounding her are attentive, sleek robotic assistants, their designs seamlessly blending form and function. The room's smart surfaces ripple with gentle, soothing patterns, responding to the occupants' emotions.",
|
111 |
+
|
112 |
+
"A breathtaking underwater research station, its transparent domes revealing a vibrant coral reef teeming with bioluminescent life. Robotic submersibles with graceful, fish-like designs glide through the water, collecting data and nurturing endangered species. Inside, scientists work alongside AI counterparts, their excited gestures visible as they make a groundbreaking discovery.",
|
113 |
+
|
114 |
+
"A serene forest glade where ancient trees intertwine with bioluminescent technological enhancements. Tiny robotic pollinators flit from flower to flower, their delicate wings shimmering in the dappled sunlight. A group of children, some human and some android, gather around a wise AI embodied in a gnarled tree trunk, listening intently to its stories of ages past and visions of the future.",
|
115 |
+
|
116 |
+
"An artist's studio aboard a space station, its large windows offering a stunning view of a distant nebula. The artist, a highly advanced android with expressive eyes, manipulates a floating, three-dimensional canvas of light and color. Robotic arms and AI-driven nanobots assist in bringing the artist's vision to life, creating a mesmerizing, ever-changing sculpture that seems to dance with the cosmos.",
|
117 |
+
|
118 |
+
"A vast, underground hydroponic farm, its tiered levels stretching as far as the eye can see. Advanced AI systems control the perfect growing conditions for a myriad of crops. Robotic tenders move efficiently between the rows, their gentle touch nurturing the plants. In a central hub, a diverse team of human and AI agronomists collaborate, developing new strains of nutrient-rich foods to sustain the growing population.",
|
119 |
+
|
120 |
+
"A futuristic classroom where students of various species – human, android, and alien – gather around a shimmering holographic display. The AI teacher, appearing as a swirling vortex of light and knowledge, adapts its form and teaching style to each student's needs. The walls of the room shift and change, transforming into immersive historical scenes or complex scientific models as the lesson progresses."
|
121 |
]
|
122 |
|
123 |
css = '''
|
|
|
186 |
)
|
187 |
|
188 |
image_gallery = gr.Gallery(label="Generated Images", show_label=True, columns=4, height="auto")
|
189 |
+
download_all_button = gr.Button("Download All Images")
|
190 |
|
191 |
gr.Examples(
|
192 |
examples=examples,
|
|
|
227 |
api_name="run",
|
228 |
)
|
229 |
|
230 |
+
download_all_button.click(
|
231 |
+
fn=create_zip_archive,
|
232 |
+
inputs=[],
|
233 |
+
outputs=gr.File(label="Download ZIP"),
|
234 |
+
)
|
235 |
+
|
236 |
demo.load(fn=update_gallery, outputs=image_gallery)
|
237 |
|
238 |
if __name__ == "__main__":
|