Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -100,23 +100,6 @@ def save_image(image):
|
|
| 100 |
print(f"Error in save_image: {str(e)}")
|
| 101 |
return None
|
| 102 |
|
| 103 |
-
def load_gallery():
|
| 104 |
-
"""Load all images from the gallery directory"""
|
| 105 |
-
try:
|
| 106 |
-
os.makedirs(gallery_path, exist_ok=True)
|
| 107 |
-
|
| 108 |
-
image_files = []
|
| 109 |
-
for f in os.listdir(gallery_path):
|
| 110 |
-
if f.lower().endswith(('.png', '.jpg', '.jpeg')):
|
| 111 |
-
full_path = os.path.join(gallery_path, f)
|
| 112 |
-
image_files.append((full_path, os.path.getmtime(full_path)))
|
| 113 |
-
|
| 114 |
-
image_files.sort(key=lambda x: x[1], reverse=True)
|
| 115 |
-
|
| 116 |
-
return [f[0] for f in image_files]
|
| 117 |
-
except Exception as e:
|
| 118 |
-
print(f"Error loading gallery: {str(e)}")
|
| 119 |
-
return []
|
| 120 |
|
| 121 |
# Create Gradio interface
|
| 122 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
@@ -183,20 +166,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 183 |
elem_id="output-image",
|
| 184 |
elem_classes=["output-image", "fixed-width"]
|
| 185 |
)
|
| 186 |
-
|
| 187 |
-
gallery = gr.Gallery(
|
| 188 |
-
label="Generated Images Gallery",
|
| 189 |
-
show_label=True,
|
| 190 |
-
elem_id="gallery",
|
| 191 |
-
columns=[4],
|
| 192 |
-
rows=[2],
|
| 193 |
-
height="auto",
|
| 194 |
-
object_fit="cover",
|
| 195 |
-
elem_classes=["gallery-container", "fixed-width"]
|
| 196 |
-
)
|
| 197 |
-
|
| 198 |
-
gallery.value = load_gallery()
|
| 199 |
-
|
| 200 |
|
| 201 |
@spaces.GPU
|
| 202 |
def process_and_save_image(height, width, steps, scales, prompt, seed):
|
|
|
|
| 100 |
print(f"Error in save_image: {str(e)}")
|
| 101 |
return None
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
# Create Gradio interface
|
| 105 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
|
|
| 166 |
elem_id="output-image",
|
| 167 |
elem_classes=["output-image", "fixed-width"]
|
| 168 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
|
| 170 |
@spaces.GPU
|
| 171 |
def process_and_save_image(height, width, steps, scales, prompt, seed):
|