LYL1015 commited on
Commit
088bb07
Β·
verified Β·
1 Parent(s): d607249

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -7
app.py CHANGED
@@ -783,15 +783,16 @@ def create_interface():
783
  # Input image upload component
784
  input_image = gr.Image(
785
  label="πŸ“Έ Upload Your Image",
786
- type="pil"
 
787
  )
788
 
789
  # Prompt input
790
  user_prompt = gr.Textbox(
791
  label="πŸ’¬ Describe Your Vision",
792
  placeholder="Describe your desired retouching style... (e.g., 'I want a dreamy, romantic sunset vibe with soft, warm colors')",
793
- lines=3,
794
- max_lines=5
795
  )
796
 
797
  # Process button
@@ -801,6 +802,10 @@ def create_interface():
801
  size="lg"
802
  )
803
 
 
 
 
 
804
 
805
  with gr.Column(scale=1):
806
  # Chat interface to show analysis
@@ -820,7 +825,7 @@ def create_interface():
820
  )
821
 
822
  # Lightroom import guide (collapsible)
823
- with gr.Accordion("🎨 Click to see how to use Lightroom Presets", open=False):
824
  gr.Markdown("""
825
  ### How to Import Lightroom Presets:
826
 
@@ -899,6 +904,21 @@ def create_interface():
899
  padding: 12px;
900
  border: 1px solid #dee2e6;
901
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
902
  </style>
903
  """)
904
 
@@ -906,12 +926,23 @@ def create_interface():
906
  examples_data = load_examples_data()
907
 
908
  if examples_data:
 
 
 
909
  # Create card-style layout for each example
910
  for i, example in enumerate(examples_data):
911
- # Card container
912
  with gr.Column(elem_classes="example-card"):
913
- # Card header
914
- gr.HTML(f'<div class="card-header">🎨 Example {example["id"]}</div>')
 
 
 
 
 
 
 
 
915
 
916
  # Card content
917
  with gr.Row():
@@ -1107,6 +1138,21 @@ def create_interface():
1107
  lambda: (10240, 50, 0.8, 0.7),
1108
  outputs=[max_new_tokens, top_k, top_p, temperature]
1109
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1110
 
1111
  return demo
1112
  if __name__ == "__main__":
 
783
  # Input image upload component
784
  input_image = gr.Image(
785
  label="πŸ“Έ Upload Your Image",
786
+ type="pil",
787
+ height=350
788
  )
789
 
790
  # Prompt input
791
  user_prompt = gr.Textbox(
792
  label="πŸ’¬ Describe Your Vision",
793
  placeholder="Describe your desired retouching style... (e.g., 'I want a dreamy, romantic sunset vibe with soft, warm colors')",
794
+ lines=6,
795
+ max_lines=8
796
  )
797
 
798
  # Process button
 
802
  size="lg"
803
  )
804
 
805
+ # Add some spacing to match right column height
806
+ gr.Markdown("") # Empty space
807
+ gr.Markdown("") # Empty space
808
+
809
 
810
  with gr.Column(scale=1):
811
  # Chat interface to show analysis
 
825
  )
826
 
827
  # Lightroom import guide (collapsible)
828
+ with gr.Accordion("🎨 How to use Lightroom Presets:", open=True):
829
  gr.Markdown("""
830
  ### How to Import Lightroom Presets:
831
 
 
904
  padding: 12px;
905
  border: 1px solid #dee2e6;
906
  }
907
+ .card-header-btn {
908
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
909
+ color: white !important;
910
+ border: none !important;
911
+ border-radius: 12px !important;
912
+ margin-bottom: 20px !important;
913
+ font-weight: bold !important;
914
+ font-size: 1.1em !important;
915
+ width: 100% !important;
916
+ transition: all 0.3s ease !important;
917
+ }
918
+ .card-header-btn:hover {
919
+ transform: translateY(-1px) !important;
920
+ box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important;
921
+ }
922
  </style>
923
  """)
924
 
 
926
  examples_data = load_examples_data()
927
 
928
  if examples_data:
929
+ # Store click buttons for event binding
930
+ example_buttons = []
931
+
932
  # Create card-style layout for each example
933
  for i, example in enumerate(examples_data):
934
+ # Card container - make it clickable
935
  with gr.Column(elem_classes="example-card"):
936
+ # Card header with click functionality
937
+ card_click_btn = gr.Button(
938
+ f"🎨 Example {example['id']} - Click to Use",
939
+ variant="secondary",
940
+ size="lg",
941
+ elem_classes="card-header-btn"
942
+ )
943
+
944
+ # Store button and example data for later binding
945
+ example_buttons.append((card_click_btn, example))
946
 
947
  # Card content
948
  with gr.Row():
 
1138
  lambda: (10240, 50, 0.8, 0.7),
1139
  outputs=[max_new_tokens, top_k, top_p, temperature]
1140
  )
1141
+
1142
+ # Bind example card click events
1143
+ if 'example_buttons' in locals() and example_buttons:
1144
+ for card_btn, example in example_buttons:
1145
+ def create_click_handler(ex):
1146
+ def handler():
1147
+ image_path = ex['original_image'] if ex['original_image'] else None
1148
+ prompt_text = ex['user_prompt'] if ex['user_prompt'] else ""
1149
+ return image_path, prompt_text
1150
+ return handler
1151
+
1152
+ card_btn.click(
1153
+ fn=create_click_handler(example),
1154
+ outputs=[input_image, user_prompt]
1155
+ )
1156
 
1157
  return demo
1158
  if __name__ == "__main__":