juaben commited on
Commit
1da87bb
·
verified ·
1 Parent(s): 3bb88a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -8
app.py CHANGED
@@ -31,6 +31,8 @@ def load_img(filename):
31
 
32
  def process_img(image, filename):
33
  # Select the correct weight file based on the image filename
 
 
34
  if filename in image_to_weights:
35
  model_path = image_to_weights[filename]
36
  checkpoints = torch.load(model_path, map_location=device)
@@ -90,17 +92,10 @@ demo = gr.Interface(
90
  css=css
91
  )
92
 
93
- # Updating the filename in the input after selection
94
- def update_filename(image):
95
- # Retrieve the filename from the input image
96
- if image:
97
- filename = image.filename # Gradio automatically gives the file name
98
- return filename
99
- return ""
100
 
101
  with gr.Blocks() as demo:
102
  with gr.Row():
103
- input_image = gr.Image(type='pil', label='input')
104
  filename_output = gr.Textbox(label="Image Filename", interactive=False)
105
 
106
  # Define the output
 
31
 
32
  def process_img(image, filename):
33
  # Select the correct weight file based on the image filename
34
+
35
+ filename = image.name.split("/")[-1]
36
  if filename in image_to_weights:
37
  model_path = image_to_weights[filename]
38
  checkpoints = torch.load(model_path, map_location=device)
 
92
  css=css
93
  )
94
 
 
 
 
 
 
 
 
95
 
96
  with gr.Blocks() as demo:
97
  with gr.Row():
98
+ input_image = gr.Image(type='pil', label='input', interactive = True)
99
  filename_output = gr.Textbox(label="Image Filename", interactive=False)
100
 
101
  # Define the output