Commit
·
732c53f
1
Parent(s):
543dbe2
Refactor app.py to simplify UI component configurations by consolidating attributes and improving readability. Update demo launch method to utilize queue for enhanced performance.
Browse files
app.py
CHANGED
|
@@ -190,64 +190,31 @@ with gr.Blocks() as demo:
|
|
| 190 |
image_input = gr.Image(
|
| 191 |
label="Image input",
|
| 192 |
image_mode="RGBA",
|
| 193 |
-
sources=
|
| 194 |
type="pil",
|
| 195 |
-
show_label=True,
|
| 196 |
-
show_download_button=False
|
| 197 |
-
)
|
| 198 |
-
processed_image = gr.Image(
|
| 199 |
-
label="Processed Image",
|
| 200 |
-
interactive=False,
|
| 201 |
-
type="pil",
|
| 202 |
-
image_mode="RGB",
|
| 203 |
-
show_label=True,
|
| 204 |
-
show_download_button=False
|
| 205 |
)
|
|
|
|
| 206 |
with gr.Row():
|
| 207 |
with gr.Column():
|
| 208 |
with gr.Row():
|
| 209 |
-
background_choice = gr.Radio(
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
back_ground_color = gr.ColorPicker(
|
| 216 |
-
label="Background Color",
|
| 217 |
-
value="#7F7F7F",
|
| 218 |
-
show_label=True
|
| 219 |
-
)
|
| 220 |
foreground_ratio = gr.Slider(
|
| 221 |
label="Foreground Ratio",
|
| 222 |
minimum=0.5,
|
| 223 |
maximum=1.0,
|
| 224 |
value=1.0,
|
| 225 |
step=0.05,
|
| 226 |
-
show_label=True
|
| 227 |
)
|
| 228 |
|
| 229 |
with gr.Column():
|
| 230 |
-
seed = gr.Number(
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
precision=0,
|
| 234 |
-
show_label=True
|
| 235 |
-
)
|
| 236 |
-
guidance_scale = gr.Number(
|
| 237 |
-
value=5.5,
|
| 238 |
-
minimum=3.0,
|
| 239 |
-
maximum=10.0,
|
| 240 |
-
label="Guidance scale",
|
| 241 |
-
show_label=True
|
| 242 |
-
)
|
| 243 |
-
step = gr.Number(
|
| 244 |
-
value=30,
|
| 245 |
-
minimum=30,
|
| 246 |
-
maximum=100,
|
| 247 |
-
label="Sample steps",
|
| 248 |
-
precision=0,
|
| 249 |
-
show_label=True
|
| 250 |
-
)
|
| 251 |
text_button = gr.Button("Generate 3D shape")
|
| 252 |
# if os.path.exists("examples") and os.listdir("examples"):
|
| 253 |
# gr.Examples(
|
|
@@ -261,8 +228,6 @@ with gr.Blocks() as demo:
|
|
| 261 |
output_model = gr.Model3D(
|
| 262 |
label="Output GLB",
|
| 263 |
interactive=False,
|
| 264 |
-
show_label=True,
|
| 265 |
-
show_download_button=True
|
| 266 |
)
|
| 267 |
gr.Markdown("Note: Ensure that the input image is correctly pre-processed into a grey background, otherwise the results will be unpredictable.")
|
| 268 |
|
|
@@ -289,11 +254,4 @@ with gr.Blocks() as demo:
|
|
| 289 |
)
|
| 290 |
|
| 291 |
if __name__ == "__main__":
|
| 292 |
-
|
| 293 |
-
demo.launch(
|
| 294 |
-
enable_queue=True,
|
| 295 |
-
api_open=True, # Enable API access
|
| 296 |
-
show_api=True, # Show API documentation
|
| 297 |
-
show_error=True,
|
| 298 |
-
allowed_paths=["examples"] # Allow access to examples directory
|
| 299 |
-
)
|
|
|
|
| 190 |
image_input = gr.Image(
|
| 191 |
label="Image input",
|
| 192 |
image_mode="RGBA",
|
| 193 |
+
sources="upload",
|
| 194 |
type="pil",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
)
|
| 196 |
+
processed_image = gr.Image(label="Processed Image", interactive=False, type="pil", image_mode="RGB")
|
| 197 |
with gr.Row():
|
| 198 |
with gr.Column():
|
| 199 |
with gr.Row():
|
| 200 |
+
background_choice = gr.Radio([
|
| 201 |
+
"Alpha as mask",
|
| 202 |
+
"Auto Remove background"
|
| 203 |
+
], value="Auto Remove background",
|
| 204 |
+
label="Background choice")
|
| 205 |
+
back_ground_color = gr.ColorPicker(label="Background Color", value="#7F7F7F")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
foreground_ratio = gr.Slider(
|
| 207 |
label="Foreground Ratio",
|
| 208 |
minimum=0.5,
|
| 209 |
maximum=1.0,
|
| 210 |
value=1.0,
|
| 211 |
step=0.05,
|
|
|
|
| 212 |
)
|
| 213 |
|
| 214 |
with gr.Column():
|
| 215 |
+
seed = gr.Number(value=1234, label="Seed", precision=0)
|
| 216 |
+
guidance_scale = gr.Number(value=5.5, minimum=3, maximum=10, label="Guidance scale")
|
| 217 |
+
step = gr.Number(value=30, minimum=30, maximum=100, label="Sample steps", precision=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
text_button = gr.Button("Generate 3D shape")
|
| 219 |
# if os.path.exists("examples") and os.listdir("examples"):
|
| 220 |
# gr.Examples(
|
|
|
|
| 228 |
output_model = gr.Model3D(
|
| 229 |
label="Output GLB",
|
| 230 |
interactive=False,
|
|
|
|
|
|
|
| 231 |
)
|
| 232 |
gr.Markdown("Note: Ensure that the input image is correctly pre-processed into a grey background, otherwise the results will be unpredictable.")
|
| 233 |
|
|
|
|
| 254 |
)
|
| 255 |
|
| 256 |
if __name__ == "__main__":
|
| 257 |
+
demo.queue().launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|