Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -851,51 +851,54 @@ def create_interface():
|
|
| 851 |
if examples_data:
|
| 852 |
# Create table header
|
| 853 |
with gr.Row():
|
| 854 |
-
with gr.Column(scale=1):
|
| 855 |
-
gr.Markdown("**Original Image**")
|
| 856 |
-
with gr.Column(scale=2):
|
| 857 |
-
gr.Markdown("**Instruction**")
|
| 858 |
with gr.Column(scale=2):
|
|
|
|
|
|
|
| 859 |
gr.Markdown("**Retouching Settings**")
|
| 860 |
-
with gr.Column(scale=
|
| 861 |
gr.Markdown("**Processed Image**")
|
| 862 |
|
| 863 |
# Create rows for each example
|
| 864 |
for i, example in enumerate(examples_data):
|
| 865 |
with gr.Row():
|
| 866 |
-
with gr.Column(scale=
|
| 867 |
if example['original_image']:
|
| 868 |
-
gr.Image(example['original_image'], label=f"Example {example['id']}", height=
|
| 869 |
else:
|
| 870 |
gr.Markdown("*No image*")
|
| 871 |
-
|
| 872 |
-
|
| 873 |
if example['user_prompt']:
|
| 874 |
-
gr.Markdown(f"*{example['user_prompt']}*")
|
| 875 |
else:
|
| 876 |
gr.Markdown("*No instruction*")
|
| 877 |
|
| 878 |
-
with gr.Column(scale=
|
| 879 |
if example['config_lua']:
|
| 880 |
-
# Show preview of config
|
| 881 |
-
config_preview = example['config_lua'][:
|
| 882 |
-
gr.Textbox(config_preview, label=f"Config Preview", lines=
|
| 883 |
|
| 884 |
# Download button
|
| 885 |
download_btn = gr.Button(f"📥 Download Preset {example['id']}", size="sm", variant="secondary")
|
| 886 |
-
download_output = gr.File(visible=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 887 |
|
| 888 |
-
# Bind download event with closure
|
| 889 |
download_btn.click(
|
| 890 |
-
fn=
|
| 891 |
outputs=download_output
|
| 892 |
)
|
| 893 |
else:
|
| 894 |
gr.Markdown("*No config file*")
|
| 895 |
|
| 896 |
-
with gr.Column(scale=
|
| 897 |
if example['processed_image']:
|
| 898 |
-
gr.Image(example['processed_image'], label=f"Result {example['id']}", height=
|
| 899 |
else:
|
| 900 |
gr.Markdown("*No result image*")
|
| 901 |
else:
|
|
|
|
| 851 |
if examples_data:
|
| 852 |
# Create table header
|
| 853 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
| 854 |
with gr.Column(scale=2):
|
| 855 |
+
gr.Markdown("**Original Image & Instruction**")
|
| 856 |
+
with gr.Column(scale=3):
|
| 857 |
gr.Markdown("**Retouching Settings**")
|
| 858 |
+
with gr.Column(scale=2):
|
| 859 |
gr.Markdown("**Processed Image**")
|
| 860 |
|
| 861 |
# Create rows for each example
|
| 862 |
for i, example in enumerate(examples_data):
|
| 863 |
with gr.Row():
|
| 864 |
+
with gr.Column(scale=2):
|
| 865 |
if example['original_image']:
|
| 866 |
+
gr.Image(example['original_image'], label=f"Example {example['id']}", height=200, interactive=False)
|
| 867 |
else:
|
| 868 |
gr.Markdown("*No image*")
|
| 869 |
+
|
| 870 |
+
# Instruction below the image
|
| 871 |
if example['user_prompt']:
|
| 872 |
+
gr.Markdown(f"**Instruction:** *{example['user_prompt']}*")
|
| 873 |
else:
|
| 874 |
gr.Markdown("*No instruction*")
|
| 875 |
|
| 876 |
+
with gr.Column(scale=3):
|
| 877 |
if example['config_lua']:
|
| 878 |
+
# Show preview of config with fixed height
|
| 879 |
+
config_preview = example['config_lua'][:300] + "..." if len(example['config_lua']) > 300 else example['config_lua']
|
| 880 |
+
gr.Textbox(config_preview, label=f"Config Preview", lines=10, max_lines=10, interactive=False)
|
| 881 |
|
| 882 |
# Download button
|
| 883 |
download_btn = gr.Button(f"📥 Download Preset {example['id']}", size="sm", variant="secondary")
|
| 884 |
+
download_output = gr.File(label="Download", visible=True, interactive=False)
|
| 885 |
+
|
| 886 |
+
# Bind download event with closure - fix the closure issue
|
| 887 |
+
def create_download_function(config_content, example_id):
|
| 888 |
+
def download_func():
|
| 889 |
+
return download_example_preset(config_content, example_id)
|
| 890 |
+
return download_func
|
| 891 |
|
|
|
|
| 892 |
download_btn.click(
|
| 893 |
+
fn=create_download_function(example['config_lua'], example['id']),
|
| 894 |
outputs=download_output
|
| 895 |
)
|
| 896 |
else:
|
| 897 |
gr.Markdown("*No config file*")
|
| 898 |
|
| 899 |
+
with gr.Column(scale=2):
|
| 900 |
if example['processed_image']:
|
| 901 |
+
gr.Image(example['processed_image'], label=f"Result {example['id']}", height=200, interactive=False)
|
| 902 |
else:
|
| 903 |
gr.Markdown("*No result image*")
|
| 904 |
else:
|