Skip to content

Requirements to build the model? #32

@Xento

Description

@Xento

Hello
I'm trying to add some own images to the model.
I'm using python 3.11 and installed the requirements with pip install -r requirements.txt

I was able to train the model but the last step where it is converted to a tflite files it fails with this error:

ValueError                                Traceback (most recent call last)
File /mnt/c/Users/marku/Tenth-of-step-of-a-meter-digit/venv_name/lib/python3.11/site-packages/tf_keras/src/engine/base_layer.py:855, in Layer.from_config(cls, config)
    854 try:
--> 855     return cls(**config)
    856 except Exception as e:

File /mnt/c/Users/marku/Tenth-of-step-of-a-meter-digit/venv_name/lib/python3.11/site-packages/tf_keras/src/utils/traceback_utils.py:70, in filter_traceback.<locals>.error_handler(*args, **kwargs)
     68     # To get the full stack trace, call:
     69     # `tf.debugging.disable_traceback_filtering()`
---> 70     raise e.with_traceback(filtered_tb) from None
     71 finally:

File /mnt/c/Users/marku/Tenth-of-step-of-a-meter-digit/venv_name/lib/python3.11/site-packages/tf_keras/src/engine/input_layer.py:153, in InputLayer.__init__(self, input_shape, batch_size, dtype, input_tensor, sparse, name, ragged, type_spec, **kwargs)
    152 if kwargs:
--> 153     raise ValueError(
    154         f"Unrecognized keyword arguments: {list(kwargs.keys())}"
    155     )
    157 if sparse and ragged:

ValueError: Unrecognized keyword arguments: ['batch_shape']

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
Cell In[2], line 4
      2 from b2n.models.prune_quantize import  quantization_default
      3 from  tensorflow import keras
----> 4 model = keras.models.load_model(output_tmp_dir + 'dig-class100-s2' + '_best.keras')
      6 # prune the model
      7 model_pruned = model

File /mnt/c/Users/marku/Tenth-of-step-of-a-meter-digit/venv_name/lib/python3.11/site-packages/tf_keras/src/saving/saving_api.py:254, in load_model(filepath, custom_objects, compile, safe_mode, **kwargs)
    249     if kwargs:
    250         raise ValueError(
    251             "The following argument(s) are not supported "
    252             f"with the native TF-Keras format: {list(kwargs.keys())}"
    253         )
--> 254     return saving_lib.load_model(
    255         filepath,
    256         custom_objects=custom_objects,
    257         compile=compile,
    258         safe_mode=safe_mode,
    259     )
    261 # Legacy case.
    262 return legacy_sm_saving_lib.load_model(
    263     filepath, custom_objects=custom_objects, compile=compile, **kwargs
    264 )

File /mnt/c/Users/marku/Tenth-of-step-of-a-meter-digit/venv_name/lib/python3.11/site-packages/tf_keras/src/saving/saving_lib.py:271, in load_model(filepath, custom_objects, compile, safe_mode)
    268             asset_store.close()
    270 except Exception as e:
--> 271     raise e
    272 else:
    273     return model

File /mnt/c/Users/marku/Tenth-of-step-of-a-meter-digit/venv_name/lib/python3.11/site-packages/tf_keras/src/saving/saving_lib.py:236, in load_model(filepath, custom_objects, compile, safe_mode)
    234 # Construct the model from the configuration file in the archive.
    235 with ObjectSharingScope():
--> 236     model = deserialize_keras_object(
    237         config_dict, custom_objects, safe_mode=safe_mode
    238     )
    240 all_filenames = zf.namelist()
    241 if _VARS_FNAME + ".h5" in all_filenames:

File /mnt/c/Users/marku/Tenth-of-step-of-a-meter-digit/venv_name/lib/python3.11/site-packages/tf_keras/src/saving/serialization_lib.py:727, in deserialize_keras_object(config, custom_objects, safe_mode, **kwargs)
    725 safe_mode_scope = SafeModeScope(safe_mode)
    726 with custom_obj_scope, safe_mode_scope:
--> 727     instance = cls.from_config(inner_config)
    728     build_config = config.get("build_config", None)
    729     if build_config:

File /mnt/c/Users/marku/Tenth-of-step-of-a-meter-digit/venv_name/lib/python3.11/site-packages/tf_keras/src/engine/sequential.py:465, in Sequential.from_config(cls, config, custom_objects)
    463 for layer_config in layer_configs:
    464     use_legacy_format = "module" not in layer_config
--> 465     layer = layer_module.deserialize(
    466         layer_config,
    467         custom_objects=custom_objects,
    468         use_legacy_format=use_legacy_format,
    469     )
    470     model.add(layer)
    472 if (
    473     not model.inputs
    474     and build_input_shape
    475     and isinstance(build_input_shape, (tuple, list))
    476 ):

File /mnt/c/Users/marku/Tenth-of-step-of-a-meter-digit/venv_name/lib/python3.11/site-packages/tf_keras/src/layers/serialization.py:276, in deserialize(config, custom_objects, use_legacy_format)
    268 if use_legacy_format:
    269     return legacy_serialization.deserialize_keras_object(
    270         config,
    271         module_objects=LOCAL.ALL_OBJECTS,
    272         custom_objects=custom_objects,
    273         printable_module_name="layer",
    274     )
--> 276 return serialization_lib.deserialize_keras_object(
    277     config,
    278     module_objects=LOCAL.ALL_OBJECTS,
    279     custom_objects=custom_objects,
    280     printable_module_name="layer",
    281 )

File /mnt/c/Users/marku/Tenth-of-step-of-a-meter-digit/venv_name/lib/python3.11/site-packages/tf_keras/src/saving/serialization_lib.py:608, in deserialize_keras_object(config, custom_objects, safe_mode, **kwargs)
    601         if isinstance(module_objects[config], types.FunctionType):
    602             return deserialize_keras_object(
    603                 serialize_with_public_fn(
    604                     module_objects[config], config, fn_module_name
    605                 ),
    606                 custom_objects=custom_objects,
    607             )
--> 608         return deserialize_keras_object(
    609             serialize_with_public_class(
    610                 module_objects[config], inner_config=inner_config
    611             ),
    612             custom_objects=custom_objects,
    613         )
    615 if isinstance(config, PLAIN_TYPES):
    616     return config

File /mnt/c/Users/marku/Tenth-of-step-of-a-meter-digit/venv_name/lib/python3.11/site-packages/tf_keras/src/saving/serialization_lib.py:727, in deserialize_keras_object(config, custom_objects, safe_mode, **kwargs)
    725 safe_mode_scope = SafeModeScope(safe_mode)
    726 with custom_obj_scope, safe_mode_scope:
--> 727     instance = cls.from_config(inner_config)
    728     build_config = config.get("build_config", None)
    729     if build_config:

File /mnt/c/Users/marku/Tenth-of-step-of-a-meter-digit/venv_name/lib/python3.11/site-packages/tf_keras/src/engine/base_layer.py:857, in Layer.from_config(cls, config)
    855     return cls(**config)
    856 except Exception as e:
--> 857     raise TypeError(
    858         f"Error when deserializing class '{cls.__name__}' using "
    859         f"config={config}.\n\nException encountered: {e}"
    860     )

TypeError: Error when deserializing class 'InputLayer' using config={'batch_shape': [None, 32, 20, 3], 'dtype': 'float32', 'sparse': False, 'ragged': False, 'name': 'input_layer_1'}.

Exception encountered: Unrecognized keyword arguments: ['batch_shape']

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions