1 Star 0 Fork 0

Friende/Image-OutPainting

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
prepare_data.py 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
bendangnuksung 提交于 2018-07-28 17:30 +08:00 . update outpaint, dataloder, add gitignore
import numpy as np
import os
import cv2
# raw_data_path: directory where the downloaded images are
# save_path: directory where the numpy images will be
raw_data_path = "data/raw_data/coast"
save_path = "data/prepared_data/"
files = os.listdir(raw_data_path)
input_shape = (256, 256)
# batch: each file will have N images
batch = 1000
# Dumping numpy batch images to save_path
counter = 1
def dumpy_numpy(data):
global counter
file_path = os.path.join(save_path, str(counter))
np.save(file_path, data)
counter += 1
# Converting to numpy files
bulk = []
if not len(files):
print("No images in: ", raw_data_path)
for i, file in enumerate(files, 1):
try:
image_path = os.path.join(raw_data_path, file)
image = cv2.imread(image_path)
image = cv2.resize(image, input_shape)
bulk.append(image)
except Exception as e:
print("error: ", e)
print("file name: ", image_path)
print("Proccessed: %s / %s image" %(i, len(files)))
if len(bulk) >= batch or i == len(files):
print("Dumping batch: ", len(bulk))
dumpy_numpy(bulk)
bulk = []
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Friende/Image-OutPainting.git
git@gitee.com:Friende/Image-OutPainting.git
Friende
Image-OutPainting
Image-OutPainting
master

搜索帮助