awacke1 commited on
Commit
a9b9785
1 Parent(s): ea5b567

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -8
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
- "An elderly man engages in a virtual reality physical therapy session, guided by a compassionate AI therapist that adapts the exercises to his abilities and provides encouragement, all from the comfort of his own home.",
97
- "In a bright, welcoming dental office, a young patient watches in awe as a dental robot efficiently and painlessly repairs a cavity using a laser system, while the dentist explains the procedure using interactive 3D images.",
98
- "A team of biomedical engineers collaborate in a state-of-the-art research facility, designing and testing advanced prosthetic limbs that seamlessly integrate with the patient's nervous system for natural, intuitive control.",
99
- "A pregnant woman undergoes a routine check-up, as a gentle robotic ultrasound system captures high-resolution 3D images of her developing baby, while the obstetrician provides reassurance and guidance via a holographic display.",
100
- "In a cutting-edge cancer treatment center, a patient undergoes a precision radiation therapy session, where an AI-guided system delivers highly targeted doses to destroy cancer cells while preserving healthy tissue.",
101
- "A group of medical students attend a virtual reality lecture, where they can interact with detailed, 3D anatomical models and simulate complex surgical procedures under the guidance of renowned experts from around the world.",
102
- "In a remote village, a local healthcare worker uses a portable, AI-powered diagnostic device to quickly and accurately assess a patient's symptoms, while seamlessly connecting with specialists in distant cities for expert advice and treatment planning.",
103
- "At an advanced fertility clinic, a couple watches in wonder as an AI-assisted system carefully selects the most viable embryos for implantation, while providing personalized guidance and emotional support throughout the process."
 
 
 
 
 
 
 
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__":