adpro commited on
Commit
ae21fa2
·
verified ·
1 Parent(s): 5687b64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -13
app.py CHANGED
@@ -45,20 +45,11 @@ def process_image(image_path):
45
  ).squeeze()
46
  output = prediction.cpu().numpy()
47
  depth_image = (output * 255 / np.max(output)).astype("uint8")
48
- depth_image_padded = np.array(
49
- ImageOps.pad(Image.fromarray(depth_image), (1280, 720))
50
  )
51
 
52
- stereo_image = stereo_converter.convert_depth_to_stereogram_with_thread_pool(
53
- depth_image_padded, False
54
- ).astype(np.uint8)
55
 
56
- stereo_image_pil = Image.fromarray(stereo_image).convert("RGB")
57
- with tempfile.NamedTemporaryFile(suffix=".jpg", delete=False) as f:
58
- image_name = f.name
59
- stereo_image_pil.save(image_name)
60
-
61
- return [depth_image_padded, stereo_image, image_name]
62
 
63
 
64
  examples_images = [[f] for f in sorted(glob.glob("examples/*.jpg"))]
@@ -90,12 +81,12 @@ to generate the autostereogram (Magic Eye)
90
  examples=examples_images,
91
  fn=process_image,
92
  inputs=[input_image],
93
- outputs=[predicted_depth, autostereogram, file_download],
94
  cache_examples=True,
95
  )
96
  button.click(
97
  fn=process_image,
98
  inputs=[input_image],
99
- outputs=[predicted_depth, autostereogram, file_download],
100
  )
101
  blocks.launch(debug=True)
 
45
  ).squeeze()
46
  output = prediction.cpu().numpy()
47
  depth_image = (output * 255 / np.max(output)).astype("uint8")
48
+ depth_image_padded = Image.fromarray(depth_image)
 
49
  )
50
 
 
 
 
51
 
52
+ return [depth_image_padded]
 
 
 
 
 
53
 
54
 
55
  examples_images = [[f] for f in sorted(glob.glob("examples/*.jpg"))]
 
81
  examples=examples_images,
82
  fn=process_image,
83
  inputs=[input_image],
84
+ outputs=[predicted_depth],
85
  cache_examples=True,
86
  )
87
  button.click(
88
  fn=process_image,
89
  inputs=[input_image],
90
+ outputs=[predicted_depth],
91
  )
92
  blocks.launch(debug=True)