umuthopeyildirim
commited on
Commit
•
c9de5c0
1
Parent(s):
5178ffd
Refactor image processing code
Browse files
app.py
CHANGED
@@ -95,20 +95,21 @@ with gr.Blocks(css=css) as demo:
|
|
95 |
# image = torch.from_numpy(image).unsqueeze(0)
|
96 |
with torch.no_grad():
|
97 |
image = torch.autograd.Variable(image.unsqueeze(0))
|
98 |
-
|
99 |
pred_depths_r_list, _, _ = model(image)
|
100 |
image_flipped = flip_lr(image)
|
101 |
pred_depths_r_list_flipped, _, _ = model(image_flipped)
|
102 |
pred_depth = post_process_depth(
|
103 |
pred_depths_r_list[-1], pred_depths_r_list_flipped[-1])
|
104 |
-
|
105 |
pred_depth = pred_depth.cpu().numpy().squeeze()
|
106 |
output_image = plt.imsave('depth.png', pred_depth, cmap='jet')
|
|
|
107 |
tmp = tempfile.NamedTemporaryFile(delete=False)
|
108 |
-
tmp.
|
109 |
-
print(tmp.
|
110 |
-
|
111 |
-
return [(original_image,
|
112 |
|
113 |
submit.click(on_submit, inputs=[input_image], outputs=[
|
114 |
depth_image_slider, raw_file])
|
|
|
95 |
# image = torch.from_numpy(image).unsqueeze(0)
|
96 |
with torch.no_grad():
|
97 |
image = torch.autograd.Variable(image.unsqueeze(0))
|
98 |
+
print("== Processing image")
|
99 |
pred_depths_r_list, _, _ = model(image)
|
100 |
image_flipped = flip_lr(image)
|
101 |
pred_depths_r_list_flipped, _, _ = model(image_flipped)
|
102 |
pred_depth = post_process_depth(
|
103 |
pred_depths_r_list[-1], pred_depths_r_list_flipped[-1])
|
104 |
+
print("== Finished processing image")
|
105 |
pred_depth = pred_depth.cpu().numpy().squeeze()
|
106 |
output_image = plt.imsave('depth.png', pred_depth, cmap='jet')
|
107 |
+
print("== Saved image"+str(output_image))
|
108 |
tmp = tempfile.NamedTemporaryFile(delete=False)
|
109 |
+
output_image.save(tmp.name)
|
110 |
+
print("== Saved image"+str(tmp.name))
|
111 |
+
|
112 |
+
return [(original_image, output_image), output_image]
|
113 |
|
114 |
submit.click(on_submit, inputs=[input_image], outputs=[
|
115 |
depth_image_slider, raw_file])
|