JackAILab commited on
Commit
71a8eaf
·
verified ·
1 Parent(s): 727d27f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -161,7 +161,6 @@ script_directory = os.path.dirname(os.path.realpath(__file__))
161
  preset_template = glob.glob("./images/templates/*.png")
162
  preset_template = preset_template + glob.glob("./images/templates/*.jpg")
163
 
164
-
165
  with gr.Blocks(title="ConsistentID_SDXL Demo") as demo:
166
  gr.Markdown("# ConsistentID_SDXL Demo")
167
  gr.Markdown("\
@@ -181,9 +180,19 @@ with gr.Blocks(title="ConsistentID_SDXL Demo") as demo:
181
 
182
  selected_template_images = gr.Text(show_label=False, visible=False, placeholder="Selected")
183
  gallery.select(select_function, None, selected_template_images)
 
184
  with gr.TabItem("Upload Image") as upload_image_tab:
185
  costum_image = gr.Image(label="Upload Image")
186
 
 
 
 
 
 
 
 
 
 
187
  model_selected_tabs = [template_images_tab, upload_image_tab]
188
  for i, tab in enumerate(model_selected_tabs):
189
  tab.select(fn=lambda tabnum=i: tabnum, inputs=[], outputs=[model_selected_tab])
 
161
  preset_template = glob.glob("./images/templates/*.png")
162
  preset_template = preset_template + glob.glob("./images/templates/*.jpg")
163
 
 
164
  with gr.Blocks(title="ConsistentID_SDXL Demo") as demo:
165
  gr.Markdown("# ConsistentID_SDXL Demo")
166
  gr.Markdown("\
 
180
 
181
  selected_template_images = gr.Text(show_label=False, visible=False, placeholder="Selected")
182
  gallery.select(select_function, None, selected_template_images)
183
+
184
  with gr.TabItem("Upload Image") as upload_image_tab:
185
  costum_image = gr.Image(label="Upload Image")
186
 
187
+ ### 回调函数:处理上传的图像路径
188
+ def handle_uploaded_image(image):
189
+ if image:
190
+ return f"Uploaded image path: {image}"
191
+ return "No image uploaded."
192
+
193
+ selected_template_images = gr.Text(show_label=False, visible=False, placeholder="Selected")
194
+ uploaded_image_path = costum_image.change(handle_uploaded_image, inputs=costum_image, outputs=selected_template_images)
195
+
196
  model_selected_tabs = [template_images_tab, upload_image_tab]
197
  for i, tab in enumerate(model_selected_tabs):
198
  tab.select(fn=lambda tabnum=i: tabnum, inputs=[], outputs=[model_selected_tab])