GonzaloMG commited on
Commit
326dd31
1 Parent(s): aeb7b27

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -83,9 +83,9 @@ description = """... **...**"""
83
  # return model.infer_image(image)
84
 
85
  @spaces.GPU
86
- def predict_depth(image): #, processing_res, model_choice, current_model):
87
  with torch.no_grad():
88
- pipe_out = pipe(image, denoising_steps=1, ensemble_size=1, noise="zeros", normals=False, processing_res=768, match_input_res=True)
89
  pred = pipe_out.depth_np
90
  pred_colored = pipe_out.depth_colored
91
  return pred, pred_colored
@@ -115,14 +115,14 @@ with gr.Blocks(css=css) as demo:
115
 
116
  cmap = matplotlib.colormaps.get_cmap('Spectral_r')
117
 
118
- def on_submit(image):
119
 
120
  if image is None:
121
  print("No image uploaded.")
122
  return None
123
 
124
  pil_image = Image.fromarray(image.astype('uint8'))
125
- depth_npy, depth_colored = predict_depth(pil_image)
126
 
127
  # Save the npy data (raw depth map)
128
  # tmp_npy_depth = tempfile.NamedTemporaryFile(suffix='.npy', delete=False)
@@ -163,7 +163,7 @@ with gr.Blocks(css=css) as demo:
163
  example_files.sort()
164
  example_files = [os.path.join('assets/examples', filename) for filename in example_files]
165
  example_files = [[image, 768] for image in example_files]
166
- examples = gr.Examples(examples=example_files, inputs=[input_image], outputs=[depth_image_slider, gray_depth_file, raw_file], fn=on_submit)
167
 
168
 
169
  if __name__ == '__main__':
 
83
  # return model.infer_image(image)
84
 
85
  @spaces.GPU
86
+ def predict_depth(image, processing_res_choice):
87
  with torch.no_grad():
88
+ pipe_out = pipe(image, denoising_steps=1, ensemble_size=1, noise="zeros", normals=False, processing_res=processing_res_choice, match_input_res=True)
89
  pred = pipe_out.depth_np
90
  pred_colored = pipe_out.depth_colored
91
  return pred, pred_colored
 
115
 
116
  cmap = matplotlib.colormaps.get_cmap('Spectral_r')
117
 
118
+ def on_submit(image, processing_res_choice):
119
 
120
  if image is None:
121
  print("No image uploaded.")
122
  return None
123
 
124
  pil_image = Image.fromarray(image.astype('uint8'))
125
+ depth_npy, depth_colored = predict_depth(pil_image, processing_res_choice)
126
 
127
  # Save the npy data (raw depth map)
128
  # tmp_npy_depth = tempfile.NamedTemporaryFile(suffix='.npy', delete=False)
 
163
  example_files.sort()
164
  example_files = [os.path.join('assets/examples', filename) for filename in example_files]
165
  example_files = [[image, 768] for image in example_files]
166
+ examples = gr.Examples(examples=example_files, inputs=[input_image, processing_res_choice], outputs=[depth_image_slider, gray_depth_file, raw_file], fn=on_submit)
167
 
168
 
169
  if __name__ == '__main__':