Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -139,15 +139,38 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
139 |
cache_examples=True # Speeds up demo loading
|
140 |
)
|
141 |
|
142 |
-
# Create
|
143 |
import os
|
144 |
from urllib.request import urlretrieve
|
|
|
|
|
145 |
os.makedirs("examples", exist_ok=True)
|
146 |
-
|
147 |
-
|
148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
|
150 |
|
151 |
# --- 5. Launch the App ---
|
|
|
152 |
if __name__ == "__main__":
|
153 |
-
demo.launch(debug=True)
|
|
|
139 |
cache_examples=True # Speeds up demo loading
|
140 |
)
|
141 |
|
142 |
+
# --- Create example files for the demo ---
|
143 |
import os
|
144 |
from urllib.request import urlretrieve
|
145 |
+
|
146 |
+
print("Creating examples directory and downloading example images...")
|
147 |
os.makedirs("examples", exist_ok=True)
|
148 |
+
|
149 |
+
# These URLs are from the stable Hugging Face documentation assets
|
150 |
+
try:
|
151 |
+
# AI Example 1: A classic AI-generated image (astronaut on a horse)
|
152 |
+
urlretrieve(
|
153 |
+
"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/horse.png",
|
154 |
+
"examples/ai_example_1.png"
|
155 |
+
)
|
156 |
+
|
157 |
+
# Human Example 1: A real photograph
|
158 |
+
urlretrieve(
|
159 |
+
"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/gradio-guide/zookeeper.png",
|
160 |
+
"examples/human_example_1.jpg"
|
161 |
+
)
|
162 |
+
|
163 |
+
# AI Example 2: An AI-generated portrait, good for testing face/hair detection
|
164 |
+
urlretrieve(
|
165 |
+
"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/stable-diffusion-sdxl/sdxl-gfpgan-output.png",
|
166 |
+
"examples/ai_example_2.png"
|
167 |
+
)
|
168 |
+
print("Example images downloaded successfully.")
|
169 |
+
except Exception as e:
|
170 |
+
print(f"Failed to download example images: {e}")
|
171 |
|
172 |
|
173 |
# --- 5. Launch the App ---
|
174 |
+
# This line was already there, just make sure it's the last part of your script
|
175 |
if __name__ == "__main__":
|
176 |
+
demo.launch(debug=True)
|