我正在训练我的实时对象检测模型,但我不知道是在命令提示符下运行命令,还是在虚拟环境的Anaconda提示符下运行命令

2024-04-27 16:48:38 发布

您现在位置:Python中文网/ 问答频道 /正文

这是命令:

python Tensorflow/models/research/object_detection/model_main_tf2.py \
  --model_dir=Tensorflow/workspace/models/my_ssd_mobnet \
  --pipeline_config_path=Tensorflow/workspace/models/my_ssd_mobnet/pipeline.config \
  --num_train_steps=10000
  1. 如果在命令提示符下运行此命令,则会出现以下错误:

    Traceback (most recent call last):
      File "Tensorflow/models/research/object_detection/model_main_tf2.py", line 31, in <module>
        import tensorflow.compat.v2 as tf
    ModuleNotFoundError: No module named 'tensorflow'
    
  2. 如果在anaconda提示符下运行此命令,则会出现以下错误:

    2021-07-17 21:22:32.101472: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
    2021-07-17 21:22:32.101744: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
    2021-07-17 21:22:41.609589: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
    2021-07-17 21:22:41.609860: W tensorflow/stream_executor/cuda/cuda_driver.cc:326] failed call to cuInit: UNKNOWN ERROR (303)
    2021-07-17 21:22:41.617530: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: Asus-VivoBook-15
    2021-07-17 21:22:41.617904: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: Asus-VivoBook-15
    2021-07-17 21:22:41.618723: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
    To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
    WARNING:tensorflow:There are non-GPU devices in `tf.distribute.Strategy`, not using nccl allreduce.
    W0717 21:22:41.615594  8792 cross_device_ops.py:1387] There are non-GPU devices in `tf.distribute.Strategy`, not using nccl allreduce.
    WARNING:tensorflow:Collective ops is not configured at program startup. Some performance features may not be enabled.
    W0717 21:22:41.615594  8792 mirrored_strategy.py:379] Collective ops is not configured at program startup. Some performance features may not be enabled.
    INFO:tensorflow:Using MirroredStrategy with devices ('/job:localhost/replica:0/task:0/device:CPU:0',)
    I0717 21:22:41.625584  8792 mirrored_strategy.py:369] Using MirroredStrategy with devices ('/job:localhost/replica:0/task:0/device:CPU:0',)
    INFO:tensorflow:Maybe overwriting train_steps: 10000
    I0717 21:22:41.635598  8792 config_util.py:552] Maybe overwriting train_steps: 10000
    INFO:tensorflow:Maybe overwriting use_bfloat16: False
    I0717 21:22:41.635598  8792 config_util.py:552] Maybe overwriting use_bfloat16: False
    WARNING:tensorflow:From C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\object_detection\model_lib_v2.py:557: StrategyBase.experimental_distribute_datasets_from_function (from tensorflow.python.distribute.distribute_lib) is deprecated and will be removed in a future version.
    Instructions for updating:
    rename to distribute_datasets_from_function
    W0717 21:22:41.835648  8792 deprecation.py:330] From C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\object_detection\model_lib_v2.py:557: StrategyBase.experimental_distribute_datasets_from_function (from tensorflow.python.distribute.distribute_lib) is deprecated and will be removed in a future version.
    Instructions for updating:
    rename to distribute_datasets_from_function
    INFO:tensorflow:Reading unweighted datasets: ['Tensorflow/workspace/annotations/train.record']
    I0717 21:22:41.845639  8792 dataset_builder.py:163] Reading unweighted datasets: ['Tensorflow/workspace/annotations/train.record']
    INFO:tensorflow:Reading record datasets for input file: ['Tensorflow/workspace/annotations/train.record']
    I0717 21:22:41.855641  8792 dataset_builder.py:80] Reading record datasets for input file: ['Tensorflow/workspace/annotations/train.record']
    INFO:tensorflow:Number of filenames to read: 1
    I0717 21:22:41.855641  8792 dataset_builder.py:81] Number of filenames to read: 1
    WARNING:tensorflow:num_readers has been reduced to 1 to match input file shards.
    W0717 21:22:41.855641  8792 dataset_builder.py:87] num_readers has been reduced to 1 to match input file shards.
    WARNING:tensorflow:From C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\object_detection\builders\dataset_builder.py:101: parallel_interleave (from tensorflow.python.data.experimental.ops.interleave_ops) is deprecated and will be removed in a future version.
    Instructions for updating:
    Use `tf.data.Dataset.interleave(map_func, cycle_length, block_length, num_parallel_calls=tf.data.AUTOTUNE)` instead. If sloppy execution is desired, use `tf.data.Options.experimental_deterministic`.
    W0717 21:22:41.855641  8792 deprecation.py:330] From C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\object_detection\builders\dataset_builder.py:101: parallel_interleave (from tensorflow.python.data.experimental.ops.interleave_ops) is deprecated and will be removed in a future version.
    Instructions for updating:
    Use `tf.data.Dataset.interleave(map_func, cycle_length, block_length, num_parallel_calls=tf.data.AUTOTUNE)` instead. If sloppy execution is desired, use `tf.data.Options.experimental_deterministic`.
    WARNING:tensorflow:From C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\object_detection\builders\dataset_builder.py:236: DatasetV1.map_with_legacy_function (from tensorflow.python.data.ops.dataset_ops) is deprecated and will be removed in a future version.
    Instructions for updating:
    Use `tf.data.Dataset.map()
    W0717 21:22:41.915656  8792 deprecation.py:330] From C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\object_detection\builders\dataset_builder.py:236: DatasetV1.map_with_legacy_function (from tensorflow.python.data.ops.dataset_ops) is deprecated and will be removed in a future version.
    Instructions for updating:
    Use `tf.data.Dataset.map()
    Traceback (most recent call last):
      File "Tensorflow/models/research/object_detection/model_main_tf2.py", line 115, in <module>
        tf.compat.v1.app.run()
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\platform\app.py", line 40, in run
        _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\absl\app.py", line 312, in run
        _run_main(main, args)
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\absl\app.py", line 258, in _run_main
        sys.exit(main(argv))
      File "Tensorflow/models/research/object_detection/model_main_tf2.py", line 106, in main
        model_lib_v2.train_loop(
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\object_detection\model_lib_v2.py", line 557, in train_loop
        train_input = strategy.experimental_distribute_datasets_from_function(
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\util\deprecation.py", line 337, in new_func
        return func(*args, **kwargs)
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\distribute\distribute_lib.py", line 1168, in experimental_distribute_datasets_from_function
        return self.distribute_datasets_from_function(dataset_fn, options)
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\distribute\distribute_lib.py", line 1159, in distribute_datasets_from_function
        return self._extended._distribute_datasets_from_function(  # pylint: disable=protected-access
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\distribute\mirrored_strategy.py", line 595, in _distribute_datasets_from_function
        return input_lib.get_distributed_datasets_from_function(
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\distribute\input_lib.py", line 167, in get_distributed_datasets_from_function
        return DistributedDatasetsFromFunction(input_workers, strategy,
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\distribute\input_lib.py", line 1565, in __init__
        _create_datasets_from_function_with_input_context(
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\distribute\input_lib.py", line 2301, in _create_datasets_from_function_with_input_context
        dataset = dataset_fn(ctx)
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\object_detection\model_lib_v2.py", line 548, in train_dataset_fn
        train_input = inputs.train_input(
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\object_detection\inputs.py", line 901, in train_input
        dataset = INPUT_BUILDER_UTIL_MAP['dataset_build'](
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\object_detection\builders\dataset_builder.py", line 251, in build
        dataset = dataset_map_fn(dataset, decoder.decode, batch_size,
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\object_detection\builders\dataset_builder.py", line 236, in dataset_map_fn
        dataset = dataset.map_with_legacy_function(
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\util\deprecation.py", line 337, in new_func
        return func(*args, **kwargs)
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 2814, in map_with_legacy_function
        ParallelMapDataset(
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 4522, in __init__
        self._map_func = StructuredFunctionWrapper(
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 3719, in __init__
        self._function.add_to_graph(ops.get_default_graph())
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\framework\function.py", line 542, in add_to_graph
        self._create_definition_if_needed()
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\framework\function.py", line 378, in _create_definition_if_needed
        self._create_definition_if_needed_impl()
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\framework\function.py", line 396, in _create_definition_if_needed_impl
        temp_graph = func_graph_from_py_func(
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\framework\function.py", line 967, in func_graph_from_py_func
        outputs = func(*func_graph.inputs)
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 3635, in wrapped_fn
        ret = wrapper_helper(*args)
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 3617, in wrapper_helper
        ret = autograph.tf_convert(self._func, ag_ctx)(*nested_args)
      File "C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\autograph\impl\api.py", line 695, in wrapper
        raise e.ag_error_metadata.to_exception(e)
    NotImplementedError: in user code:
        C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\object_detection\data_decoders\tf_example_decoder.py:533 default_groundtruth_weights  *
            [tf.shape(tensor_dict[fields.InputDataFields.groundtruth_boxes])[0]],
        C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\util\dispatch.py:206 wrapper  **
            return target(*args, **kwargs)
        C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\ops\array_ops.py:3212 ones
            output = _constant_if_small(one, shape, dtype, name)
        C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\ops\array_ops.py:2896 _constant_if_small
            if np.prod(shape) < 1000:
        <__array_function__ internals>:5 prod
        C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\numpy\core\fromnumeric.py:3030 prod
            return _wrapreduction(a, np.multiply, 'prod', axis, dtype, out,
        C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\numpy\core\fromnumeric.py:87 _wrapreduction
            return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
        C:\Users\bhanu\anaconda3\envs\tfod\lib\site-packages\tensorflow\python\framework\ops.py:867 __array__
            raise NotImplementedError(
        NotImplementedError: Cannot convert a symbolic Tensor (cond_2/strided_slice:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported 
    
  3. 注:我已安装Tensorflow&;Anaconda虚拟环境中的Numpy

    • Python版本:3.8
    • Numpy版本:1.20.1

Tags: inpylibpackagestensorflowlinesiteusers