From b74b9c54247177c82493f180617d7551de8e2bb1 Mon Sep 17 00:00:00 2001 From: natanielruiz <nataniel777@hotmail.com> Date: 星期二, 26 九月 2017 03:47:06 +0800 Subject: [PATCH] Before SR experiments --- code/test_on_video.py | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git a/code/test_on_video.py b/code/test_on_video.py index 8d6c5fd..c837775 100644 --- a/code/test_on_video.py +++ b/code/test_on_video.py @@ -48,7 +48,7 @@ # ResNet101 with 3 outputs. # model = hopenet.Hopenet(torchvision.models.resnet.Bottleneck, [3, 4, 23, 3], 66) # ResNet50 - model = hopenet.Hopenet(torchvision.models.resnet.Bottleneck, [3, 4, 6, 3], 66) + model = hopenet.Hopenet(torchvision.models.resnet.Bottleneck, [3, 4, 6, 3], 66, 0) # ResNet18 # model = hopenet.Hopenet(torchvision.models.resnet.BasicBlock, [2, 2, 2, 2], 66) @@ -60,7 +60,7 @@ print 'Loading data.' transformations = transforms.Compose([transforms.Scale(224), - transforms.RandomCrop(224), transforms.ToTensor(), + transforms.CenterCrop(224), transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])]) model.cuda(gpu) @@ -75,11 +75,21 @@ idx_tensor = torch.FloatTensor(idx_tensor).cuda(gpu) video = cv2.VideoCapture(video_path) - width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH)) # float - height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT)) # float + + # New cv2 + # width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH)) # float + # height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT)) # float + # + # # Define the codec and create VideoWriter object + # fourcc = cv2.VideoWriter_fourcc(*'MJPG') + # out = cv2.VideoWriter('output/video/output-%s.avi' % args.output_string, fourcc, 30.0, (width, height)) + + # Old cv2 + width = int(video.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)) # float + height = int(video.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)) # float # Define the codec and create VideoWriter object - fourcc = cv2.VideoWriter_fourcc(*'MJPG') + fourcc = cv2.cv.CV_FOURCC(*'MJPG') out = cv2.VideoWriter('output/video/output-%s.avi' % args.output_string, fourcc, 30.0, (width, height)) txt_out = open('output/video/output-%s.txt' % args.output_string, 'w') -- Gitblit v1.8.0