深度学习:图像分类与目标检测
肺炎预测的 CNN 模型应用
代码实现
以下是使用预训练的 CNN 模型对新图像集进行肺炎预测的代码:
import numpy as np
import pathlib
import cv2
import tensorflow as tf
import matplotlib.pyplot as plt
model_path = "models/pneumiacnn"
val_img_dir = "images/chest_xray/val"
# ImageDataGenerator class provides a mechanism to load both small and large dataset.
# Instruct ImageDataGenerator to scale to normalize pixel values to range (0, 1)
datagen = tf.keras.preprocessing.image.ImageDataGenerator(rescale=1./255.)
# Create a training image iterator that will be loaded in a small batch size. Resize all images to a #standard size.
val_it = datagen.flow_from_directory(val_img_dir, batch_size=8, target_size=(1024,1024))
# Load and create the exact sa
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



