本文整理匯總了Python中util.load_image方法的典型用法代碼示例。如果您正苦於以下問題:Python util.load_image方法的具體用法?Python util.load_image怎麽用?Python util.load_image使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類util
的用法示例。
在下文中一共展示了util.load_image方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: import util [as 別名]
# 或者: from util import load_image [as 別名]
def main():
if len(sys.argv) < 4:
print_usage()
dataset = sys.argv[1]
base_dir = sys.argv[2]
out_file = sys.argv[3]
names = util.load_names(dataset)
centers = []
for idx, name in enumerate(names):
if dataset == 'nyu': # use synthetic image to compute center
name = name.replace('depth', 'synthdepth')
img = util.load_image(dataset, os.path.join(base_dir, name))
if dataset == 'icvl':
center = util.get_center(img, upper=500, lower=0)
elif dataset == 'nyu':
center = util.get_center(img, upper=1300, lower=500)
elif dataset == 'msra':
center = util.get_center(img, upper=1000, lower=10)
centers.append(center.reshape((1, 3)))
if idx % 500 == 0:
print('{}/{}'.format(idx + 1, len(names)))
util.save_results(centers, out_file)
示例2: show_pose
# 需要導入模塊: import util [as 別名]
# 或者: from util import load_image [as 別名]
def show_pose(dataset_model, dataset_image, base_dir, outputs, list_file, save_dir,
is_flip, gif):
if list_file is None:
names = util.load_names(dataset_image)
else:
with open(list_file) as f:
names = [line.strip() for line in f]
assert len(names) == outputs.shape[0]
for idx, (name, pose) in enumerate(zip(names, outputs)):
img = util.load_image(dataset_image, os.path.join(base_dir, name),
is_flip=is_flip)
img = img.astype(np.float32)
img = (img - img.min()) / (img.max() - img.min()) * 255
img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
img = util.draw_pose(dataset_model, img, pose)
cv2.imshow('result', img / 255)
if save_dir is not None:
cv2.imwrite(os.path.join(save_dir, '{:>06d}.png'.format(idx)), img)
ch = cv2.waitKey(25)
if ch == ord('q'):
break
if gif and save_dir is not None:
os.system('convert -loop 0 -page +0+0 -delay 25 {0}/*.png {0}/output.gif'.format(save_dir))
示例3: __getitem__
# 需要導入模塊: import util [as 別名]
# 或者: from util import load_image [as 別名]
def __getitem__(self, index):
albedo = load_image(join(self.albedo_path, self.image_filenames[index]))
depth = load_image(join(self.depth_path, self.image_filenames[index]))
direct = load_image(join(self.direct_path, self.image_filenames[index]))
normal = load_image(join(self.normal_path, self.image_filenames[index]))
gt = load_image(join(self.gt_path, self.image_filenames[index]))
return albedo, direct, normal, depth, gt
示例4: detect_files
# 需要導入模塊: import util [as 別名]
# 或者: from util import load_image [as 別名]
def detect_files(self, base_dir, names, centers=None, dataset=None, max_batch=64, is_flip=False):
assert max_batch > 0
if dataset is None:
dataset = self._dataset
batch_imgs = []
batch_centers = []
results = []
for idx, name in enumerate(names):
img = util.load_image(dataset, os.path.join(base_dir, name),
is_flip=is_flip)
batch_imgs.append(img)
if centers is None:
batch_centers.append(self._center_loader(img))
else:
batch_centers.append(centers[idx, :])
if len(batch_imgs) == max_batch:
for line in self.detect_images(batch_imgs, batch_centers):
results.append(line)
del batch_imgs[:]
del batch_centers[:]
print('{}/{}'.format(idx + 1, len(names)))
if batch_imgs:
for line in self.detect_images(batch_imgs, batch_centers):
results.append(line)
print('done!')
return np.array(results)