Update app.py
Browse files
app.py
CHANGED
|
@@ -80,7 +80,7 @@ def warpImage(im, vx, vy, cast_uint8=True):
|
|
| 80 |
#XX = XX + vx
|
| 81 |
XX = np.concatenate([XX, vx], axis = 1)
|
| 82 |
#YY = YY + vy
|
| 83 |
-
YY = np.concatenate([YY, vy], axis =
|
| 84 |
mask = (XX < 1) | (XX > width2) | (YY < 1) | (YY > height2)
|
| 85 |
XX = np.clip(XX, 1, width2)
|
| 86 |
YY = np.clip(XX, 1, height2)
|
|
@@ -195,21 +195,23 @@ def infer():
|
|
| 195 |
flow_img = flow_to_image(predicted_flow).to("cpu")
|
| 196 |
# output_folder = "/tmp/" # Update this to the folder of your choice
|
| 197 |
write_jpeg(flow_img, f"predicted_flow.jpg")
|
|
|
|
|
|
|
| 198 |
flo_file = write_flo(predicted_flow, "flofile.flo")
|
| 199 |
#write_jpeg(frames[100], f"input_image.jpg")
|
| 200 |
#res = warp_image(img1_batch, predicted_flow)
|
| 201 |
|
| 202 |
# define a transform to convert a tensor to PIL image
|
| 203 |
-
transform = T.ToPILImage()
|
| 204 |
|
| 205 |
# convert the tensor to PIL image using above transform
|
| 206 |
-
img = transform(frames[100])
|
| 207 |
|
| 208 |
# display the PIL image
|
| 209 |
#img.show()
|
| 210 |
-
img.save('frame_input.jpg')
|
| 211 |
-
res = get_warp_res("frame_input.jpg", predicted_flow, fname_output='warped.png')
|
| 212 |
-
print(res)
|
| 213 |
return "done", "predicted_flow.jpg", ["flofile.flo"], 'frame_input.jpg'
|
| 214 |
####################################
|
| 215 |
# Bonus: Creating GIFs of predicted flows
|
|
|
|
| 80 |
#XX = XX + vx
|
| 81 |
XX = np.concatenate([XX, vx], axis = 1)
|
| 82 |
#YY = YY + vy
|
| 83 |
+
YY = np.concatenate([YY, vy], axis = 1)
|
| 84 |
mask = (XX < 1) | (XX > width2) | (YY < 1) | (YY > height2)
|
| 85 |
XX = np.clip(XX, 1, width2)
|
| 86 |
YY = np.clip(XX, 1, height2)
|
|
|
|
| 195 |
flow_img = flow_to_image(predicted_flow).to("cpu")
|
| 196 |
# output_folder = "/tmp/" # Update this to the folder of your choice
|
| 197 |
write_jpeg(flow_img, f"predicted_flow.jpg")
|
| 198 |
+
input_image = flow_to_image(img1_batch).to("cpu")
|
| 199 |
+
write_jpeg(input_image, f"frame_input.jpg")
|
| 200 |
flo_file = write_flo(predicted_flow, "flofile.flo")
|
| 201 |
#write_jpeg(frames[100], f"input_image.jpg")
|
| 202 |
#res = warp_image(img1_batch, predicted_flow)
|
| 203 |
|
| 204 |
# define a transform to convert a tensor to PIL image
|
| 205 |
+
#transform = T.ToPILImage()
|
| 206 |
|
| 207 |
# convert the tensor to PIL image using above transform
|
| 208 |
+
#img = transform(frames[100])
|
| 209 |
|
| 210 |
# display the PIL image
|
| 211 |
#img.show()
|
| 212 |
+
#img.save('frame_input.jpg')
|
| 213 |
+
#res = get_warp_res("frame_input.jpg", predicted_flow, fname_output='warped.png')
|
| 214 |
+
#print(res)
|
| 215 |
return "done", "predicted_flow.jpg", ["flofile.flo"], 'frame_input.jpg'
|
| 216 |
####################################
|
| 217 |
# Bonus: Creating GIFs of predicted flows
|