belos 是我的代码,用于确保文件夹中有图像,但 tf.keras.preprocessing.image_dataset_from_directory 返回未找到图像。我做错了什么?谢谢。
DATASET_PATH = pathlib.Path('C:\\Users\\xxx\\Documents\\images')
image_count = len(list(DATASET_PATH.glob('.\\*.jpg')))
print(image_count)
Run Code Online (Sandbox Code Playgroud)
输出 = 2715
batch_size = 4
img_height = 32
img_width = 32
train_ds = tf.keras.preprocessing.image_dataset_from_directory(
DATASET_PATH.name,
validation_split=0.8,
subset="training",
seed=123,
image_size=(img_height, img_width),
batch_size=batch_size)
Run Code Online (Sandbox Code Playgroud)
输出:
Found 0 files belonging to 0 classes.
Using 0 files for training.
Traceback (most recent call last):
File ".\tensorDataPreProcessed.py", line 23, in <module>
batch_size=batch_size)
File "C:\Users\xxx\Anaconda3\envs\xxx\lib\site-packages\tensorflow\python\keras\preprocessing\image_dataset.py", line 200, in image_dataset_from_directory
raise ValueError('No images found.')
ValueError: No images found.
Run Code Online (Sandbox Code Playgroud) 我正在尝试加载从 pusher tfx 管道生成的 .pb 文件。我正在使用以下函数加载文件,但我从该函数中收到以下错误。请帮忙。
错误:
<ipython-input-40-af7ef7ac8a8b> in load_model()
2 with tf.compat.v2.io.gfile.GFile('/home//saved_model.pb', "rb") as f:
3 graph_def = tf.compat.v1.GraphDef()
----> 4 graph_def.ParseFromString(f.read())
5
6 with tf.Graph().as_default() as graph:
DecodeError: Error parsing message
Run Code Online (Sandbox Code Playgroud)
功能
def load_model():
with tf.compat.v2.io.gfile.GFile('/home/saved_model.pb', "rb") as f:
graph_def = tf.compat.v1.GraphDef()
graph_def.ParseFromString(f.read())
with tf.Graph().as_default() as graph:
tf.import_graph_def(graph_def, name="")
return graph
Run Code Online (Sandbox Code Playgroud) 我有一个输出a = "[1,2,3]",如何将它a = [1,2,3]从 Python 中的字符串转换为数组?
谢谢!