- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试使用 Tensorflow 读取和解码图像文件。我有以下代码:
dir_path = os.path.dirname(os.path.realpath(__file__))
filename = dir_path + '/images/cat/cat1.jpg'
image_file = tf.read_file(filename)
image_decoded = tf.image.decode_jpeg(image_file, channels=3)
print(image_file)
print(image_decoded)
这会产生以下输出:
Tensor("ReadFile:0", shape=(), dtype=string)
张量("DecodeJpeg:0", shape=(?, ?, 3), dtype=uint8)
Tensorflow 似乎根本没有读取该文件。但是我找不到任何表明出现问题的错误消息。我不知道如何解决这个问题,如有任何帮助,我们将不胜感激!
最佳答案
Tensorflow 创建一个计算图,然后对其进行评估。您在结果中看到的是创建的操作。您需要定义一个 Session 对象来获取您的操作结果。
dir_path = os.path.dirname(os.path.realpath(__file__))
filename = dir_path + '/images/cat/cat1.jpg'
image_file = tf.read_file(filename)
image_decoded = tf.image.decode_jpeg(image_file, channels=3)
with tf.Session() as sess:
f, img = sess.run([image_file, image_decoded])
print(f)
print(img)
看看这个 tensorflow帮助您进一步了解的资源!
关于python - Tensorflow read_file() 什么都不做,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52747947/
我正在做我的项目,使用我使用 codeigniter 创建的网页更新 BIND 服务器中 named.conf.local 的内容。当我运行它时,文件无法写入。这些是我的 Controller 代码:
我正在尝试使用 Tensorflow 读取和解码图像文件。我有以下代码: dir_path = os.path.dirname(os.path.realpath(__file__)) filename
提问 我循环用file_get_contents抓取一堆url,但总是会在不到第100个URL的时候停下,提示我:“Warning: file_get_contents(URL) [function
我正在尝试在 geopandas 中打开一个形状文件,如下所示: import geopandas as gpd shp = gpd.read_file("C:\my_file.shp") 但这会返回
我正在编写一个应用程序来使用 Python(使用 Pydicom 库)处理 DICOM 图像。不幸的是,根据我阅读的教程(例如 here),我一开始就遇到了一个不应该存在的问题。 代码很简单,就是这样
我在使用 geopanda 的 read_file() 读取 geojson 时收到以下警告: ...geodataframe.py:422: RuntimeWarning: Sequential r
我正在使用 File::Slurp read_file和 write_file更新文件内容的功能。 现在我专注于向它添加错误处理。为此,我尝试对实际不存在的文件执行以下方法。 1) read_file
我有一堆 DICOM 图像,我正在使用 Python dicom 包读取这些图像: my_dicom = dicom.read_file('my_dicom.dcm') my_dicom = my_
我想知道 configparser 中 read 和 read_file 的使用有什么区别。据我测试 config_parser = configparser.ConfigParser() confi
我是一名优秀的程序员,十分优秀!