Tensorflow2.0学习笔记(九)Resnet实战

0 数据

说明:忽略数据的合理性,本数据为测试代码使用的。

Tensorflow2.0学习笔记(九)Resnet实战_第1张图片

Tensorflow2.0学习笔记(九)Resnet实战_第2张图片

Tensorflow2.0学习笔记(九)Resnet实战_第3张图片

 

1 data_process.py

import tensorflow as tf
import numpy as np
import os
import cv2


def read_imgs_to_arr(imgs_path):
    imgs = []
    for img_path in imgs_path:
        img = cv2.imread(img_path)
        imgs.append(np.array(img) / 255.0)
    return imgs


def get_ImgsAndLabel(data_path):
    imgs_name = []
    labels_name = []
    for label_name in os.listdir(data_path):
        for img_name in os.listdir(data_path + label_name):
            if os.path.isfile(data_path + label_name + '/' + img_name):
                imgs_name.append(data_path + label_name + '/' + img_name)
      

你可能感兴趣的:(Tensorflow2.0)