Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,7 +48,7 @@ def load_generated_images():
|
|
| 48 |
|
| 49 |
# Load all images from the directory
|
| 50 |
image_files = [os.path.join(SAVE_DIR, f) for f in os.listdir(SAVE_DIR)
|
| 51 |
-
|
| 52 |
# Sort by creation time (newest first)
|
| 53 |
image_files.sort(key=lambda x: os.path.getctime(x), reverse=True)
|
| 54 |
return image_files
|
|
@@ -58,7 +58,7 @@ def load_predefined_images():
|
|
| 58 |
return []
|
| 59 |
|
| 60 |
@spaces.GPU(duration=120)
|
| 61 |
-
def
|
| 62 |
prompt: str,
|
| 63 |
seed: int,
|
| 64 |
randomize_seed: bool,
|
|
@@ -109,11 +109,10 @@ footer {
|
|
| 109 |
}
|
| 110 |
"""
|
| 111 |
|
| 112 |
-
|
| 113 |
-
with gr.Blocks(show_api=False, theme="Yntec/HaleyCH_Theme_Orange", css=css, analytics_enabled=False) as demo:
|
| 114 |
gr.HTML('<div class="title"> FLUX Ghibli LoRA</div>')
|
| 115 |
gr.HTML('<div class="title">😄Image to Video Explore: <a href="https://huggingface.co/spaces/ginigen/theater" target="_blank">https://huggingface.co/spaces/ginigen/theater</a></div>')
|
| 116 |
-
|
| 117 |
with gr.Tabs() as tabs:
|
| 118 |
with gr.Tab("Generation"):
|
| 119 |
with gr.Column(elem_id="col-container"):
|
|
@@ -126,9 +125,9 @@ with gr.Blocks(show_api=False, theme="Yntec/HaleyCH_Theme_Orange", css=css, anal
|
|
| 126 |
container=False,
|
| 127 |
)
|
| 128 |
run_button = gr.Button("Run", scale=0)
|
| 129 |
-
|
| 130 |
result = gr.Image(label="Result", show_label=False)
|
| 131 |
-
|
| 132 |
with gr.Accordion("Advanced Settings", open=False):
|
| 133 |
seed = gr.Slider(
|
| 134 |
label="Seed",
|
|
@@ -138,7 +137,7 @@ with gr.Blocks(show_api=False, theme="Yntec/HaleyCH_Theme_Orange", css=css, anal
|
|
| 138 |
value=42,
|
| 139 |
)
|
| 140 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
| 141 |
-
|
| 142 |
with gr.Row():
|
| 143 |
width = gr.Slider(
|
| 144 |
label="Width",
|
|
@@ -154,7 +153,7 @@ with gr.Blocks(show_api=False, theme="Yntec/HaleyCH_Theme_Orange", css=css, anal
|
|
| 154 |
step=32,
|
| 155 |
value=768,
|
| 156 |
)
|
| 157 |
-
|
| 158 |
with gr.Row():
|
| 159 |
guidance_scale = gr.Slider(
|
| 160 |
label="Guidance scale",
|
|
@@ -177,13 +176,13 @@ with gr.Blocks(show_api=False, theme="Yntec/HaleyCH_Theme_Orange", css=css, anal
|
|
| 177 |
step=0.1,
|
| 178 |
value=1.0,
|
| 179 |
)
|
| 180 |
-
|
| 181 |
gr.Examples(
|
| 182 |
examples=examples,
|
| 183 |
inputs=[prompt],
|
| 184 |
outputs=[result, seed],
|
| 185 |
)
|
| 186 |
-
|
| 187 |
with gr.Tab("Gallery"):
|
| 188 |
gallery_header = gr.Markdown("### Generated Images Gallery")
|
| 189 |
generated_gallery = gr.Gallery(
|
|
@@ -195,20 +194,21 @@ with gr.Blocks(show_api=False, theme="Yntec/HaleyCH_Theme_Orange", css=css, anal
|
|
| 195 |
height="auto"
|
| 196 |
)
|
| 197 |
refresh_btn = gr.Button("🔄 Refresh Gallery")
|
| 198 |
-
|
| 199 |
-
|
|
|
|
| 200 |
def refresh_gallery():
|
| 201 |
return load_generated_images()
|
| 202 |
-
|
| 203 |
refresh_btn.click(
|
| 204 |
fn=refresh_gallery,
|
| 205 |
inputs=None,
|
| 206 |
outputs=generated_gallery,
|
| 207 |
)
|
| 208 |
-
|
| 209 |
gr.on(
|
| 210 |
triggers=[run_button.click, prompt.submit],
|
| 211 |
-
fn=
|
| 212 |
inputs=[
|
| 213 |
prompt,
|
| 214 |
seed,
|
|
@@ -223,4 +223,4 @@ with gr.Blocks(show_api=False, theme="Yntec/HaleyCH_Theme_Orange", css=css, anal
|
|
| 223 |
)
|
| 224 |
|
| 225 |
demo.queue()
|
| 226 |
-
demo.launch()
|
|
|
|
| 48 |
|
| 49 |
# Load all images from the directory
|
| 50 |
image_files = [os.path.join(SAVE_DIR, f) for f in os.listdir(SAVE_DIR)
|
| 51 |
+
if f.endswith(('.png', '.jpg', '.jpeg', '.webp'))]
|
| 52 |
# Sort by creation time (newest first)
|
| 53 |
image_files.sort(key=lambda x: os.path.getctime(x), reverse=True)
|
| 54 |
return image_files
|
|
|
|
| 58 |
return []
|
| 59 |
|
| 60 |
@spaces.GPU(duration=120)
|
| 61 |
+
def inference(
|
| 62 |
prompt: str,
|
| 63 |
seed: int,
|
| 64 |
randomize_seed: bool,
|
|
|
|
| 109 |
}
|
| 110 |
"""
|
| 111 |
|
| 112 |
+
with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css, analytics_enabled=False) as demo:
|
|
|
|
| 113 |
gr.HTML('<div class="title"> FLUX Ghibli LoRA</div>')
|
| 114 |
gr.HTML('<div class="title">😄Image to Video Explore: <a href="https://huggingface.co/spaces/ginigen/theater" target="_blank">https://huggingface.co/spaces/ginigen/theater</a></div>')
|
| 115 |
+
|
| 116 |
with gr.Tabs() as tabs:
|
| 117 |
with gr.Tab("Generation"):
|
| 118 |
with gr.Column(elem_id="col-container"):
|
|
|
|
| 125 |
container=False,
|
| 126 |
)
|
| 127 |
run_button = gr.Button("Run", scale=0)
|
| 128 |
+
|
| 129 |
result = gr.Image(label="Result", show_label=False)
|
| 130 |
+
|
| 131 |
with gr.Accordion("Advanced Settings", open=False):
|
| 132 |
seed = gr.Slider(
|
| 133 |
label="Seed",
|
|
|
|
| 137 |
value=42,
|
| 138 |
)
|
| 139 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
| 140 |
+
|
| 141 |
with gr.Row():
|
| 142 |
width = gr.Slider(
|
| 143 |
label="Width",
|
|
|
|
| 153 |
step=32,
|
| 154 |
value=768,
|
| 155 |
)
|
| 156 |
+
|
| 157 |
with gr.Row():
|
| 158 |
guidance_scale = gr.Slider(
|
| 159 |
label="Guidance scale",
|
|
|
|
| 176 |
step=0.1,
|
| 177 |
value=1.0,
|
| 178 |
)
|
| 179 |
+
|
| 180 |
gr.Examples(
|
| 181 |
examples=examples,
|
| 182 |
inputs=[prompt],
|
| 183 |
outputs=[result, seed],
|
| 184 |
)
|
| 185 |
+
|
| 186 |
with gr.Tab("Gallery"):
|
| 187 |
gallery_header = gr.Markdown("### Generated Images Gallery")
|
| 188 |
generated_gallery = gr.Gallery(
|
|
|
|
| 194 |
height="auto"
|
| 195 |
)
|
| 196 |
refresh_btn = gr.Button("🔄 Refresh Gallery")
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
# Event handlers
|
| 200 |
def refresh_gallery():
|
| 201 |
return load_generated_images()
|
| 202 |
+
|
| 203 |
refresh_btn.click(
|
| 204 |
fn=refresh_gallery,
|
| 205 |
inputs=None,
|
| 206 |
outputs=generated_gallery,
|
| 207 |
)
|
| 208 |
+
|
| 209 |
gr.on(
|
| 210 |
triggers=[run_button.click, prompt.submit],
|
| 211 |
+
fn=inference,
|
| 212 |
inputs=[
|
| 213 |
prompt,
|
| 214 |
seed,
|
|
|
|
| 223 |
)
|
| 224 |
|
| 225 |
demo.queue()
|
| 226 |
+
demo.launch()
|