1 Star 0 Fork 271

rikun/verification-decoder

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
image_utils.py 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
import numpy as np
import glob
import code_utils as cu
from PIL import Image
class ImageUtils():
def __init__(self):
self.test_data = glob.glob('test-images/*.jpeg')
self.test_label = np.array(
[cu.in_transition(self.test_data[index].split('/')[-1].split('.')[0].split('_')[0]) for index in
range(len(self.test_data))])
self.train_data = glob.glob('train-images/*.jpeg')
self.train_label = np.array(
[cu.in_transition(self.train_data[index].split('/')[-1].split('.')[0].split('_')[0]) for index in
range(len(self.train_data))])
@staticmethod
def sample(capacity, batch_size, datas, labels):
sample_index = np.random.choice(capacity, batch_size)
_datas = np.array([np.array(Image.open(datas[index]).convert("1"))[:, :, np.newaxis] for index in sample_index])
_labels = labels[sample_index, :]
return _datas, _labels
@staticmethod
def trainstion_data(datas, sample_index=None, start=0, end=1000):
if sample_index != None:
return np.array(
[np.array(Image.open(datas[index]).convert("1"))[:, :, np.newaxis] for index in sample_index])
return np.array(
[np.array(Image.open(datas[index]).convert("1"))[:, :, np.newaxis] for index in range(start, end)])
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/rikun/verification-decoder.git
git@gitee.com:rikun/verification-decoder.git
rikun
verification-decoder
verification-decoder
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385