Update app.py
Browse files
app.py
CHANGED
@@ -95,12 +95,15 @@ def infer():
|
|
95 |
video_url = "https://download.pytorch.org/tutorial/pexelscom_pavel_danilyuk_basketball_hd.mp4"
|
96 |
video_path = Path(tempfile.mkdtemp()) / "basketball.mp4"
|
97 |
_ = urlretrieve(video_url, video_path)
|
98 |
-
|
99 |
frames, _, _ = read_video(str(video_path), output_format="TCHW")
|
100 |
-
print(f"FRAME BEFORE: {frames[100]}")
|
|
|
101 |
img1_batch = torch.stack([frames[100]])
|
102 |
img2_batch = torch.stack([frames[101]])
|
103 |
-
|
|
|
|
|
104 |
weights = Raft_Large_Weights.DEFAULT
|
105 |
transforms = weights.transforms()
|
106 |
|
@@ -175,6 +178,9 @@ def infer():
|
|
175 |
#print(flow_imgs)
|
176 |
|
177 |
predicted_flow = list_of_flows[-1][0]
|
|
|
|
|
|
|
178 |
flow_img = flow_to_image(predicted_flow).to("cpu")
|
179 |
# output_folder = "/tmp/" # Update this to the folder of your choice
|
180 |
write_jpeg(flow_img, f"predicted_flow.jpg")
|
@@ -196,7 +202,7 @@ def infer():
|
|
196 |
# display the PIL image
|
197 |
#img.show()
|
198 |
img.save('frame_input.jpg')
|
199 |
-
res = get_warp_res('frame_input.jpg', "predicted_flow.jpg", 'warped.png')
|
200 |
#print(res)
|
201 |
return "done", "predicted_flow.jpg", ["flofile.flo"], 'frame_input.jpg'
|
202 |
####################################
|
|
|
95 |
video_url = "https://download.pytorch.org/tutorial/pexelscom_pavel_danilyuk_basketball_hd.mp4"
|
96 |
video_path = Path(tempfile.mkdtemp()) / "basketball.mp4"
|
97 |
_ = urlretrieve(video_url, video_path)
|
98 |
+
|
99 |
frames, _, _ = read_video(str(video_path), output_format="TCHW")
|
100 |
+
print(f"FRAME BEFORE stack: {frames[100]}")
|
101 |
+
|
102 |
img1_batch = torch.stack([frames[100]])
|
103 |
img2_batch = torch.stack([frames[101]])
|
104 |
+
|
105 |
+
print(f"FRAME AFTER stack: {img1_batch}")
|
106 |
+
|
107 |
weights = Raft_Large_Weights.DEFAULT
|
108 |
transforms = weights.transforms()
|
109 |
|
|
|
178 |
#print(flow_imgs)
|
179 |
|
180 |
predicted_flow = list_of_flows[-1][0]
|
181 |
+
print(f"predicted flow dtype = {predicted_flows.dtype}")
|
182 |
+
print(f"predicted flow shape = {predicted_flows.shape}")
|
183 |
+
|
184 |
flow_img = flow_to_image(predicted_flow).to("cpu")
|
185 |
# output_folder = "/tmp/" # Update this to the folder of your choice
|
186 |
write_jpeg(flow_img, f"predicted_flow.jpg")
|
|
|
202 |
# display the PIL image
|
203 |
#img.show()
|
204 |
img.save('frame_input.jpg')
|
205 |
+
#res = get_warp_res('frame_input.jpg', "predicted_flow.jpg", 'warped.png')
|
206 |
#print(res)
|
207 |
return "done", "predicted_flow.jpg", ["flofile.flo"], 'frame_input.jpg'
|
208 |
####################################
|