Spaces:
Sleeping
Sleeping
on cache
Browse files
app.py
CHANGED
|
@@ -638,12 +638,21 @@ def build_ui():
|
|
| 638 |
output_image = gr.Image(label="Result (Image)", type="pil")
|
| 639 |
output_video = gr.Video(label="Result (Video)")
|
| 640 |
|
| 641 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 642 |
gr.Examples(
|
| 643 |
examples=[
|
| 644 |
["examples/cat.jpg", "BRIA-RMBG 1.4 (fast, general)", "green_screen", "720p", 0.25],
|
| 645 |
],
|
| 646 |
inputs=[input_file, image_model_dropdown, output_type, max_res, edge_quality],
|
|
|
|
|
|
|
|
|
|
|
|
|
| 647 |
label="Examples"
|
| 648 |
)
|
| 649 |
|
|
|
|
| 638 |
output_image = gr.Image(label="Result (Image)", type="pil")
|
| 639 |
output_video = gr.Video(label="Result (Video)")
|
| 640 |
|
| 641 |
+
# Wrapper for examples (auto-detects file type)
|
| 642 |
+
def process_example(file_path, image_model_choice, output_type, max_resolution, edge_quality):
|
| 643 |
+
file_type = detect_file_type(file_path)
|
| 644 |
+
return process_media(file_path, file_type, image_model_choice, output_type, max_resolution, edge_quality)
|
| 645 |
+
|
| 646 |
+
# Example files with cached results
|
| 647 |
gr.Examples(
|
| 648 |
examples=[
|
| 649 |
["examples/cat.jpg", "BRIA-RMBG 1.4 (fast, general)", "green_screen", "720p", 0.25],
|
| 650 |
],
|
| 651 |
inputs=[input_file, image_model_dropdown, output_type, max_res, edge_quality],
|
| 652 |
+
outputs=[output_image, output_video],
|
| 653 |
+
fn=process_example,
|
| 654 |
+
cache_examples=True,
|
| 655 |
+
cache_mode="lazy",
|
| 656 |
label="Examples"
|
| 657 |
)
|
| 658 |
|