Upload 4 files
Browse files
Huperflow_image.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4b730ee80bf2d27a42f73f529a1fb9dbd6015161c4f36396a46f6b311f9d4f64
|
| 3 |
+
size 2035884283
|
human_response/HuPerFlow_AveragedPerceivedFlow.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
human_response/HuPerFlow_RawPerceivedFlow.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
human_response/example_to_load_data.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import print_function, division
|
| 2 |
+
import argparse
|
| 3 |
+
import os
|
| 4 |
+
import copy
|
| 5 |
+
import numpy as np
|
| 6 |
+
from PIL import Image
|
| 7 |
+
import torch
|
| 8 |
+
import torch.nn as nn
|
| 9 |
+
import torch.nn.functional as F
|
| 10 |
+
import re
|
| 11 |
+
import glob
|
| 12 |
+
import torchvision
|
| 13 |
+
import cv2
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
DEVICE = 'cuda'
|
| 17 |
+
maindir = 'path to the selected kitti 2015 dataset'
|
| 18 |
+
datasetName = ["1_KITTI"]
|
| 19 |
+
# csvprename={'KITTI', 'vkitti','MPI','VIPER','Spring','Monkaa','MHOF','Driving','FT3D' ,'TartanAir'};
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
datasetN = len(datasetName)
|
| 23 |
+
sessionN = 12
|
| 24 |
+
movN = 2
|
| 25 |
+
frameN = 15
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def load_image(imfile):
|
| 29 |
+
img = np.array(Image.open(imfile)).astype(np.uint8)
|
| 30 |
+
if len(img.shape) == 2:
|
| 31 |
+
img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
|
| 32 |
+
cv2.imshow('image', img[:, :, [2, 1, 0]] / 255.0)
|
| 33 |
+
img = torch.from_numpy(img).permute(2, 0, 1).float()
|
| 34 |
+
return img[None].to(DEVICE)
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def save_video(flo, img, writer):
|
| 38 |
+
# map flow to rgb image
|
| 39 |
+
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
| 40 |
+
flo = cv2.cvtColor(flo, cv2.COLOR_BGR2RGB)
|
| 41 |
+
print(flo.shape)
|
| 42 |
+
img_flo = np.concatenate([img, flo], axis=0).astype(np.uint8)
|
| 43 |
+
writer.write(img_flo)
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
def demo(args):
|
| 47 |
+
for dataset in range(datasetN): # ten dataset in total
|
| 48 |
+
for session in range(1, sessionN + 1):
|
| 49 |
+
destination_folder = os.path.join(maindir, datasetName[dataset], f'session{session:03d}')
|
| 50 |
+
video_file = os.path.join(destination_folder, f'session{session:03d}.mp4')
|
| 51 |
+
|
| 52 |
+
out = None
|
| 53 |
+
for file in glob.glob(os.path.join(destination_folder, 'flow_*.mat')):
|
| 54 |
+
os.remove(file)
|
| 55 |
+
|
| 56 |
+
for mov in range(1, movN + 1):
|
| 57 |
+
image_list_ = glob.glob(os.path.join(destination_folder, f'Mov{mov}_F*.jpg'))
|
| 58 |
+
|
| 59 |
+
if len(image_list_) == 0:
|
| 60 |
+
image_list_ = glob.glob(os.path.join(destination_folder, f'Mov{mov}_F*.png'))
|
| 61 |
+
image_list_.sort(key=lambda x: int(re.sub('\D', '', x)))
|
| 62 |
+
|
| 63 |
+
print(image_list_)
|
| 64 |
+
|
| 65 |
+
# load all images
|
| 66 |
+
image_list = [load_image(img) for img in image_list_]
|
| 67 |
+
# resize the image to that divisible by 8
|
| 68 |
+
image_size_ori = image_list[0].shape[-2:]
|
| 69 |
+
image_size = [(image_size_ori[0] // 8 + 1) * 8, (image_size_ori[1] // 8 + 1) * 8]
|
| 70 |
+
image_list_resize = [F.interpolate(img, size=image_size, mode='bicubic', align_corners=True) for img in
|
| 71 |
+
image_list]
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
if __name__ == '__main__':
|
| 75 |
+
demo()
|