diff --git a/demo.py b/demo.py index ed7b517..43d76bb 100644 --- a/demo.py +++ b/demo.py @@ -25,7 +25,7 @@ import torchvision.transforms as transforms import torchvision.datasets as dset -from scipy.misc import imread +# from scipy.misc import imread from roi_data_layer.roidb import combined_roidb from roi_data_layer.roibatchLoader import roibatchLoader from model.utils.config import cfg, cfg_from_file, cfg_from_list, get_output_dir @@ -260,14 +260,9 @@ def _get_image_blob(im): # Load the demo image else: im_file = os.path.join(args.image_dir, imglist[num_images]) - im_in = np.array(imread(im_file)) - # resize - # im_in = np.array(Image.fromarray(im_in).resize((640, 360))) - if len(im_in.shape) == 2: - im_in = im_in[:,:,np.newaxis] - im_in = np.concatenate((im_in,im_in,im_in), axis=2) - # rgb -> bgr - im = im_in[:,:,::-1] + im_in = cv2.imread(im_file) + # bgr + im = im_in blobs, im_scales = _get_image_blob(im) assert len(im_scales) == 1, "Only single-image batch implemented" diff --git a/lib/roi_data_layer/minibatch.py b/lib/roi_data_layer/minibatch.py index 9a0bf02..7aa8c42 100755 --- a/lib/roi_data_layer/minibatch.py +++ b/lib/roi_data_layer/minibatch.py @@ -10,9 +10,10 @@ from __future__ import division from __future__ import print_function +import cv2 import numpy as np import numpy.random as npr -from scipy.misc import imread +# from scipy.misc import imread from model.utils.config import cfg from model.utils.blob import prep_im_for_blob, im_list_to_blob import pdb @@ -70,15 +71,16 @@ def _get_image_blob(roidb, scale_inds): processed_ims = [] im_scales = [] for i in range(num_images): - #im = cv2.imread(roidb[i]['image']) - im = imread(roidb[i]['image']) + im = cv2.imread(roidb[i]['image']) + # im = imread(roidb[i]['image']) - if len(im.shape) == 2: - im = im[:,:,np.newaxis] - im = np.concatenate((im,im,im), axis=2) + # if len(im.shape) == 2: + # im = im[:,:,np.newaxis] + # im = np.concatenate((im,im,im), axis=2) # flip the channel, since the original one using cv2 # rgb -> bgr - im = im[:,:,::-1] + # im = im[:,:,::-1] + if roidb[i]['flipped']: im = im[:, ::-1, :]