Keltezaa commited on
Commit
871c311
·
verified ·
1 Parent(s): 696ba23

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -0
app.py CHANGED
@@ -382,6 +382,13 @@ def add_custom_lora(custom_lora, selected_indices, current_loras, gallery, reque
382
  return (current_loras, gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), selected_indices, gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(),gr.update(),
383
  )
384
 
 
 
 
 
 
 
 
385
  def remove_custom_lora(selected_indices, current_loras, gallery):
386
  if current_loras:
387
  custom_lora_repo = current_loras[-1]['repo']
@@ -734,11 +741,13 @@ with gr.Blocks(theme=gr.themes.Soft(font=font), css=css, delete_cache=(128, 256)
734
  inputs=[custom_lora, selected_indices, loras_state, gallery],
735
  outputs=[loras_state, gallery, selected_info_1, selected_info_2, selected_info_3, selected_info_4, selected_indices, lora_scale_1, lora_scale_2, lora_scale_3, lora_scale_4, lora_image_1, lora_image_2, lora_image_3, lora_image_4]
736
  )
 
737
  remove_custom_lora_button.click(
738
  remove_custom_lora,
739
  inputs=[selected_indices, loras_state, gallery],
740
  outputs=[loras_state, gallery, selected_info_1, selected_info_2, selected_info_3, selected_info_4, selected_indices, lora_scale_1, lora_scale_2, lora_scale_3, lora_scale_4, lora_image_1, lora_image_2, lora_image_3, lora_image_4]
741
  )
 
742
  gr.on(
743
  triggers=[generate_button.click, prompt.submit],
744
  fn=run_lora,
 
382
  return (current_loras, gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), selected_indices, gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(),gr.update(),
383
  )
384
 
385
+ def process_custom_lora(custom_lora, request: gr.Request):
386
+ # Extract user token from request headers
387
+ user_token = request.headers.get("Authorization", "").replace("Bearer ", "")
388
+ if not user_token:
389
+ raise gr.Error("User is not logged in. Please log in to use this feature.")
390
+ return check_custom_model(custom_lora, token=user_token)
391
+
392
  def remove_custom_lora(selected_indices, current_loras, gallery):
393
  if current_loras:
394
  custom_lora_repo = current_loras[-1]['repo']
 
741
  inputs=[custom_lora, selected_indices, loras_state, gallery],
742
  outputs=[loras_state, gallery, selected_info_1, selected_info_2, selected_info_3, selected_info_4, selected_indices, lora_scale_1, lora_scale_2, lora_scale_3, lora_scale_4, lora_image_1, lora_image_2, lora_image_3, lora_image_4]
743
  )
744
+
745
  remove_custom_lora_button.click(
746
  remove_custom_lora,
747
  inputs=[selected_indices, loras_state, gallery],
748
  outputs=[loras_state, gallery, selected_info_1, selected_info_2, selected_info_3, selected_info_4, selected_indices, lora_scale_1, lora_scale_2, lora_scale_3, lora_scale_4, lora_image_1, lora_image_2, lora_image_3, lora_image_4]
749
  )
750
+
751
  gr.on(
752
  triggers=[generate_button.click, prompt.submit],
753
  fn=run_lora,