python - 用 16 位图像训练 keras ResNet50V2?
问题描述
我有 3 通道 tif 图像(16 位)。现在,我想将它们用作来自 keras 的预训练 ResNet50V2 上的训练图像。我明白,我应该tf.keras.applications.resnet_v2.preprocess_input
在使用 ImageDataGenerators 时调用 as 预处理函数。我查阅了函数(preprocess_input)的文档,它至少告诉我它需要 8 位数据。有没有办法将 16 位图像提供给 ImageDataGenerator?
或者我是否必须在将图像输入 ImageDataGenerator 之前将它们转换为 8 位?
我很高兴有任何建议!
解决方案
我在您链接的文档中没有看到对 8 位数据的引用。
是的,它可以接受 16 位:
import tensorflow as tf
import numpy as np
x = np.random.randint(0, 256, (1, 224, 224, 3), dtype=np.uint16)
tf.keras.applications.resnet_v2.preprocess_input(x)
array([[[[ 0.43529415, -0.24705881, -0.23137254],
[-0.81960785, 0.3411765 , -0.5921569 ],
[-0.7882353 , 0.58431375, 0.0196079 ],
...,
[-0.60784316, -0.4980392 , 1. ],
[-0.654902 , 0.99215686, -0.38039213],
[ 0.03529418, -0.7411765 , -0.8901961 ]]]], dtype=float32)
推荐阅读
- javascript - 反应本机收到此错误:“[未处理的承诺拒绝:SyntaxError:JSON Parse 错误:意外的标识符“Employee”]”
- python - Spinner、ToggleButton 存储值并在按下按钮时打印
- python - 内部服务器错误:尝试使用烧瓶邮件时
- azure-devops - Azure Pipelines:访问自托管 Windows 代理上的网络驱动器?
- javascript - 如何从视频播放器的“标题”中消除路径
- c# - 将 C# 字符串数组传递给 C++
- ios - 在 Ionic React 中收听 iOS Capacitor 通知
- pyqt - 在类 __init__ 中创建的 PyQt 窗口不显示
- javascript - 带有嵌套代码的 javascript .forEach 循环
- javascript - 如何将 node.js 脚本输出定向到 html 页面中的文本区域?