首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >禁止在tensorflow中加载tiff图像的警告似乎不起作用?

禁止在tensorflow中加载tiff图像的警告似乎不起作用?
EN

Stack Overflow用户
提问于 2021-05-11 06:46:14
回答 1查看 243关注 0票数 0

在使用蒂夫时,我一直收到以下警告。我发现它很好,但我一直给出这些警告,我想加以压制。

TIFFFetchNormalTag: Warning, ASCII value for tag "DateTime" contains null byte in value; value incorrectly truncated during reading due to implementation limitations.

我使用它的方式如下:

代码语言:javascript
复制
string = tf.io.read_file(filename)
image = tfio.experimental.image.decode_tiff(string) # this line produces warning

如果我试图使用warning来抑制警告,它似乎不起作用吗?它没有给我一个错误,但它什么也没做。

代码语言:javascript
复制
import warnings
warnings.filterwarnings('ignore', message='ASCII value for tag "DateTime" contains null byte in value; value incorrectly truncated during reading due to implementation limitations')

如何抑制此警告,或解决产生此警告的问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-11 16:03:40

如果你想压制所有的警告,那么你可以使用

代码语言:javascript
复制
  warnings.filterwarnings("ignore")

如果想抑制某些消息,那么您必须在消息开始时使用message=...,或者在开始时使用.*

代码语言:javascript
复制
  warnings.filterwarnings("ignore", message=".*ASCII value for tag")

最起码的例子:

代码语言:javascript
复制
import warnings

warnings.filterwarnings("ignore", message=".*ASCII value for tag")

# some tests - it should be supressed by `filterwarnings()`
warnings.warn('TIFFFetchNormalTag: Warning, ASCII value for tag "DateTime" contains null byte in value; value incorrectly truncated during reading due to implementation limitations.')

print("Hello World")
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67481782

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档