本文整理汇总了Python中pylab.imread方法的典型用法代码示例。如果您正苦于以下问题:Python pylab.imread方法的具体用法?Python pylab.imread怎么用?Python pylab.imread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylab
的用法示例。
在下文中一共展示了pylab.imread方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import imread [as 别名]
def __init__(self, image_path, title, ignore_ssids=[]):
self._image_path = image_path
self._title = title
self._ignore_ssids = ignore_ssids
logger.debug(
'Initialized HeatMapGenerator; image_path=%s title=%s',
self._image_path, self._title
)
self._layout = imread(self._image_path)
self._image_width = len(self._layout[0])
self._image_height = len(self._layout) - 1
logger.debug(
'Loaded image with width=%d height=%d',
self._image_width, self._image_height
)
with open('%s.json' % self._title, 'r') as fh:
self._data = json.loads(fh.read())
logger.info('Loaded %d measurement points', len(self._data))
示例2: predict_mask
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import imread [as 别名]
def predict_mask(image_file, smooth=True):
im = pylab.imread(image_file)
net.blobs['images'].data[0] = preprocess(im, 321)
net.forward()
scores = np.transpose(net.blobs['fc8-prod'].data[0], [1, 2, 0])
d1, d2 = float(im.shape[0]), float(im.shape[1])
scores_exp = np.exp(scores - np.max(scores, axis=2, keepdims=True))
probs = scores_exp / np.sum(scores_exp, axis=2, keepdims=True)
probs = nd.zoom(probs, (d1 / probs.shape[0], d2 / probs.shape[1], 1.0), order=1)
eps = 0.00001
probs[probs < eps] = eps
if smooth:
result = np.argmax(krahenbuhl2013.CRF(im, np.log(probs), scale_factor=1.0), axis=2)
else:
result = np.argmax(probs, axis=2)
return result
示例3: myimread
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import imread [as 别名]
def myimread(imgname, flip=False, resize=None):
"""
read an image
"""
img = None
if imgname.split(".")[-1] == "png":
img = pylab.imread(imgname)
else:
img = numpy.ascontiguousarray(pylab.imread(imgname)[::-1])
if flip:
img = numpy.ascontiguousarray(img[:, ::-1, :])
if resize != None:
from scipy.misc import imresize
img = imresize(img, resize)
return img
示例4: predict_mask
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import imread [as 别名]
def predict_mask(image_file, smooth=True):
im = pylab.imread(image_file)
d1, d2 = float(im.shape[0]), float(im.shape[1])
scores_all = 0
for size in [481]:
im_process = preprocess(im, size)
net.blobs['images'].reshape(*im_process.shape)
net.blobs['images'].data[...] = im_process
net.forward()
scores = np.transpose(net.blobs['fc8-SEC'].data[0], [1, 2, 0])
scores = nd.zoom(scores, (d1 / scores.shape[0], d2 / scores.shape[1], 1.0), order=1)
scores_all += scores
scores_exp = np.exp(scores_all - np.max(scores_all, axis=2, keepdims=True))
probs = scores_exp / np.sum(scores_exp, axis=2, keepdims=True)
eps = 0.00001
probs[probs < eps] = eps
if smooth:
result = np.argmax(krahenbuhl2013.CRF(im, np.log(probs), scale_factor=1.0), axis=2)
# result = np.argmax(dense_crf(probs, im), axis=2)
else:
result = np.argmax(probs, axis=2)
return result.copy()
示例5: predict_mask
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import imread [as 别名]
def predict_mask(image_file, smooth, labels):
im = pylab.imread(image_file)
net.blobs['images'].data[0] = preprocess(im, 321)
net.forward()
scores = np.transpose(net.blobs['fc8-SEC'].data[0], [1, 2, 0])
d1, d2 = float(im.shape[0]), float(im.shape[1])
scores_exp = np.exp(scores - np.max(scores, axis=2, keepdims=True))
probs = scores_exp / np.sum(scores_exp, axis=2, keepdims=True)
probs = nd.zoom(probs, (d1 / probs.shape[0], d2 / probs.shape[1], 1.0), order=1)
eps = 0.00001
probs[probs < eps] = eps
if smooth:
probs = krahenbuhl2013.CRF(im, np.log(probs), scale_factor=1.0)
labels = labels.tolist()
labels.insert(0, 0)
probs_selected = probs[:, :, labels]
probs_c = np.argmax(probs_selected, axis=2)
result = np.vectorize(lambda x: labels[x])(probs_c)
prob_max = np.max(probs, axis=2)
# result[prob_max < 0.85] = 255
return result
示例6: predict_mask
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import imread [as 别名]
def predict_mask(image_file, smooth=True):
im = pylab.imread(image_file)
d1, d2 = float(im.shape[0]), float(im.shape[1])
scores_all = 0
for size in [0.75, 1, 1.25]: #[385, 513, 641]
im_process = preprocess(im, size)
net.blobs['images'].reshape(*im_process.shape)
net.blobs['images'].data[...] = im_process
net.forward()
scores = np.transpose(net.blobs['fc8-SEC'].data[0], [1, 2, 0])
scores = nd.zoom(scores, (d1 / scores.shape[0], d2 / scores.shape[1], 1.0), order=1)
scores_all += scores
scores_exp = np.exp(scores_all - np.max(scores_all, axis=2, keepdims=True))
probs = scores_exp / np.sum(scores_exp, axis=2, keepdims=True)
eps = 0.00001
probs[probs < eps] = eps
if smooth:
result = np.argmax(krahenbuhl2013.CRF(im, np.log(probs), scale_factor=1.0), axis=2)
# result = np.argmax(dense_crf(probs, im), axis=2)
else:
result = np.argmax(probs, axis=2)
return result
示例7: predict_mask
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import imread [as 别名]
def predict_mask(image_file, smooth=True):
im = pylab.imread(image_file)
d1, d2 = float(im.shape[0]), float(im.shape[1])
scores_all = 0
for size in [241, 321, 401]:
im_process = preprocess(im, size)
net.blobs['images'].reshape(*im_process.shape)
net.blobs['images'].data[...] = im_process
net.forward()
scores = np.transpose(net.blobs['fc8-SEC'].data[0], [1, 2, 0])
scores = nd.zoom(scores, (d1 / scores.shape[0], d2 / scores.shape[1], 1.0), order=1)
scores_all += scores
scores_exp = np.exp(scores_all - np.max(scores_all, axis=2, keepdims=True))
probs = scores_exp / np.sum(scores_exp, axis=2, keepdims=True)
eps = 0.00001
probs[probs < eps] = eps
if smooth:
result = np.argmax(krahenbuhl2013.CRF(im, np.log(probs), scale_factor=1.0), axis=2)
# result = np.argmax(dense_crf(probs, im), axis=2)
else:
result = np.argmax(probs, axis=2)
return result
示例8: load
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import imread [as 别名]
def load(im_fname, gray = False):
if im_fname.endswith('.gif'):
print "GIFs don't load correctly for some reason"
ut.fail('fail')
im = from_pil(Image.open(im_fname))
# use imread, then flip upside down
#im = np.array(list(reversed(pylab.imread(im_fname)[:,:,:3])))
if gray:
return luminance(im)
elif not gray and np.ndim(im) == 2:
return rgb_from_gray(im)
else:
return im
示例9: get_model_download
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import imread [as 别名]
def get_model_download(self, model_id, filename=None,
output_filename=None):
"""Download a particular file associated with a given model or all its
files as a COMBINE archive.
:param model_id: a valid BioModels identifier
:param str filename: this is the requested filename to be found in the
model
:param str output_filename: if you request a different output filename,
use this parameter
:param frmt: format of the output (json, xml, html)
:return: nothing. This function save the model into a ZIP file called
after the model identifier. If parameter *filename* is specified,
then the output file is the requested filename (if found)
::
bm.get_model_download("BIOMD0000000100", filename="BIOMD0000000100.png")
bm.get_model_download("BIOMD0000000100")
This function can retrieve all files in a ZIP archive or a single image.
In the example below, we retrieve the PNG and plot it using matplotlib.
Using your favorite image viewver, you should get a better resolution.
Or just download the SVG version of the model.
.. plot::
:include-source:
from bioservices import BioModels
bm = BioModels()
from easydev import TempFile
with TempFile(suffix=".png") as fout:
bm.get_model_download("BIOMD0000000100",
filename="BIOMD0000000100.png",
output_filename=fout.name)
from pylab import imshow, imread
imshow(imread(fout.name), aspect="auto")
"""
params = {}
if filename:
params["filename"] = filename
res = self.http_get("model/download/{}".format(model_id),
params=params)
if filename:
self.logging.info("Saving {}".format(filename))
if output_filename is None:
output_filename = filename
with open(output_filename, "wb") as fout:
fout.write(res.content)
else:
self.logging.info("Saving file {}.zip".format(model_id) )
if output_filename is None:
output_filename = "{}.zip".format(model_id)
with open(output_filename, "wb") as fout:
fout.write(res.content)