nonebot-plugin-nsfw icon indicating copy to clipboard operation
nonebot-plugin-nsfw copied to clipboard

【报错求助】启动时报错

Open wuyufeng9960 opened this issue 5 months ago • 1 comments

2025-07-28 18:29:27.702746: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
WARNING:tensorflow:From F:\Hoshino-BOT\.venv\lib\site-packages\tf_keras\src\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.

WARNING:tensorflow:From F:\Hoshino-BOT\.venv\lib\site-packages\tensorflow_hub\resolver.py:120: The name tf.gfile.MakeDirs is deprecated. Please use tf.io.gfile.makedirs instead.

WARNING:tensorflow:From F:\Hoshino-BOT\.venv\lib\site-packages\tensorflow_hub\resolver.py:120: The name tf.gfile.MakeDirs is deprecated. Please use tf.io.gfile.makedirs instead.

07-28 18:29:30 [ERROR] nonebot_plugin_nsfw | Error when deserializing class 'KerasLayer' using config={'name': 'keras_layer', 'trainable': True, 'dtype': 'float32', 'handle': 'https://tfhub.dev/google/imagenet/mobilenet_v2_140_224/feature_vector/4', 'input_shape': [None, 224, 224, 3]}.

Exception encountered: Trying to load a model of incompatible/unknown type. 'C:\Users\Admin\AppData\Local\Temp\tfhub_modules\e2ca59248fa837fc8308f9ba8711723a88799917' contains neither 'saved_model.pb' nor 'saved_model.pbtxt'.
Traceback (most recent call last):
  File "F:\Hoshino-BOT\.venv\lib\site-packages\tf_keras\src\engine\base_layer.py", line 861, in from_config
    return cls(**config)
  File "F:\Hoshino-BOT\.venv\lib\site-packages\tensorflow_hub\keras_layer.py", line 165, in __init__
    self._func = load_module(handle, tags, self._load_options)
  File "F:\Hoshino-BOT\.venv\lib\site-packages\tensorflow_hub\keras_layer.py", line 467, in load_module
    return module_v2.load(handle, tags=tags, options=set_load_options)
  File "F:\Hoshino-BOT\.venv\lib\site-packages\tensorflow_hub\module_v2.py", line 113, in load
    raise ValueError("Trying to load a model of incompatible/unknown type. "
ValueError: Trying to load a model of incompatible/unknown type. 'C:\Users\Admin\AppData\Local\Temp\tfhub_modules\e2ca59248fa837fc8308f9ba8711723a88799917' contains neither 'saved_model.pb' nor 'saved_model.pbtxt'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\threading.py", line 973, in _bootstrap
    self._bootstrap_inner()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
> File "F:\Hoshino-BOT\.venv\lib\site-packages\nonebot_plugin_nsfw\loader.py", line 136, in _ctx_loader
    _loader()
  File "F:\Hoshino-BOT\.venv\lib\site-packages\nonebot_plugin_nsfw\loader.py", line 87, in load_nsfw_model
    model = load_model(model_path)
  File "F:\Hoshino-BOT\.venv\lib\site-packages\nonebot_plugin_nsfw\vendor_nsfw_model.py", line 70, in load_model
    model = tf.keras.models.load_model(
  File "F:\Hoshino-BOT\.venv\lib\site-packages\keras\src\saving\saving_api.py", line 196, in load_model
    return legacy_h5_format.load_model_from_hdf5(
  File "F:\Hoshino-BOT\.venv\lib\site-packages\keras\src\legacy\saving\legacy_h5_format.py", line 133, in load_model_from_hdf5
    model = saving_utils.model_from_config(
  File "F:\Hoshino-BOT\.venv\lib\site-packages\keras\src\legacy\saving\saving_utils.py", line 88, in model_from_config
    return serialization.deserialize_keras_object(
  File "F:\Hoshino-BOT\.venv\lib\site-packages\keras\src\legacy\saving\serialization.py", line 495, in deserialize_keras_object
    deserialized_obj = cls.from_config(
  File "F:\Hoshino-BOT\.venv\lib\site-packages\keras\src\models\sequential.py", line 366, in from_config
    layer = saving_utils.model_from_config(
  File "F:\Hoshino-BOT\.venv\lib\site-packages\keras\src\legacy\saving\saving_utils.py", line 88, in model_from_config
    return serialization.deserialize_keras_object(
  File "F:\Hoshino-BOT\.venv\lib\site-packages\keras\src\legacy\saving\serialization.py", line 504, in deserialize_keras_object
    deserialized_obj = cls.from_config(cls_config)
  File "F:\Hoshino-BOT\.venv\lib\site-packages\tf_keras\src\engine\base_layer.py", line 863, in from_config
    raise TypeError(
TypeError: Error when deserializing class 'KerasLayer' using config={'name': 'keras_layer', 'trainable': True, 'dtype': 'float32', 'handle': 'https://tfhub.dev/google/imagenet/mobilenet_v2_140_224/feature_vector/4', 'input_shape': [None, 224, 224, 3]}.

Exception encountered: Trying to load a model of incompatible/unknown type. 'C:\Users\Admin\AppData\Local\Temp\tfhub_modules\e2ca59248fa837fc8308f9ba8711723a88799917' contains neither 'saved_model.pb' nor 'saved_model.pbtxt'.

翻阅了所有的issue没有查询到相似问题,求解决!

wuyufeng9960 avatar Jul 28 '25 10:07 wuyufeng9960

是 nsfw-model 吗?试下直接下载 https://github.com/iyume/nonebot-plugin-nsfw/releases/download/v0.0/nsfw_mobilenet2_v1.2.0.h5 然后放到目录下,根据 README 在 bot config 添加模型路径配置

iyume avatar Jul 31 '25 10:07 iyume