def _transform(self, filename):
try:
image = misc.imread(filename)
if len(image.shape) < 3: # make sure images are of shape(h,w,3)
image = np.array([image for i in range(3)])
if self.image_options.get("resize", False) and self.image_options["resize"]:
resize_size = int(self.image_options["resize_size"])
resize_image = misc.imresize(image,
[resize_size, resize_size])
else:
resize_image = image
if self.image_options.get("color", False):
option = self.image_options['color']
if option == "LAB":
resize_image = color.rgb2lab(resize_image)
elif option == "HSV":
resize_image = color.rgb2hsv(resize_image)
except:
print ("Error reading file: %s of shape %s" % (filename, str(image.shape)))
raise
return np.array(resize_image)
BatchDatsetReader.py 文件源码
python
阅读 20
收藏 0
点赞 0
评论 0
评论列表
文章目录