我正在尝试在 Google Colab 上训练我的模型。当我在集成了 google colab 的笔记本中运行培训部分时,它给了我一个错误,我找不到任何解决方案。谁能解释我是什么问题,我该如何解决它。
错误:
Requirement already satisfied: tf_slim in /usr/local/lib/python3.7/dist-packages (1.1.0)
Requirement already satisfied: absl-py>=0.2.2 in /usr/local/lib/python3.7/dist-packages (from tf_slim) (0.12.0)
Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from absl-py>=0.2.2->tf_slim) (1.15.0)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
/content/gdrive/My Drive/models/research/object_detection
WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/absl/app.py:251: main (from __main__) is deprecated and will be removed in a future version.
Instructions for updating:
Use object_detection/model_main.py.
W0709 08:26:23.871510 140330500528000 deprecation.py:323] From /usr/local/lib/python3.7/dist-packages/absl/app.py:251: main (from __main__) is deprecated and will be removed in a future version.
Instructions for updating:
Use object_detection/model_main.py.
WARNING:tensorflow:From /content/gdrive/My Drive/models/research/object_detection/legacy/trainer.py:265: create_global_step (from tf_slim.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Please switch to tf.train.create_global_step
W0709 08:26:24.229744 140330500528000 deprecation.py:323] From /content/gdrive/My Drive/models/research/object_detection/legacy/trainer.py:265: create_global_step (from tf_slim.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Please switch to tf.train.create_global_step
Traceback (most recent call last):
File "train.py", line 186, in <module>
tf.app.run()
File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 303, in run
_run_main(main, args)
File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 251, in _run_main
sys.exit(main(argv))
File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/util/deprecation.py", line 324, in new_func
return func(*args, **kwargs)
File "train.py", line 182, in main
graph_hook_fn=graph_rewriter_fn)
File "/content/gdrive/My Drive/models/research/object_detection/legacy/trainer.py", line 279, in train
train_config.prefetch_queue_capacity, data_augmentation_options)
File "/content/gdrive/My Drive/models/research/object_detection/legacy/trainer.py", line 58, in create_input_queue
tensor_dict = create_tensor_dict_fn()
File "train.py", line 123, in get_next
dataset_builder.build(config)).get_next()
File "/content/gdrive/My Drive/models/research/object_detection/builders/dataset_builder.py", line 210, in build
decoder = decoder_builder.build(input_reader_config)
File "/content/gdrive/My Drive/models/research/object_detection/builders/decoder_builder.py", line 64, in build
load_keypoint_depth_features=input_reader_config
File "/content/gdrive/My Drive/models/research/object_detection/data_decoders/tf_example_decoder.py", line 421, in __init__
default_value=''),
File "/content/gdrive/My Drive/models/research/object_detection/data_decoders/tf_example_decoder.py", line 89, in __init__
label_map_proto_file, use_display_name=False)
TypeError: get_label_map_dict() got an unexpected keyword argument 'use_display_name'
这是我有序运行的代码块:
!pip install --upgrade pip
!pip install --upgrade protobuf
%tensorflow_version 1.15
import tensorflow as tf
print(tf.__version__)
!pip install numpy
device_name = tf.test.gpu_device_name()
if device_name != '/device:GPU:0':
raise SystemError('GPU device not found')
print('Found GPU at: {}'.format(device_name))
# memory footprint support libraries/code
!ln -sf /opt/bin/nvidia-smi /usr/bin/nvidia-smi
!pip install gputil
!pip install psutil
!pip install humanize
import psutil
import humanize
import os
import GPUtil as GPU
GPUs = GPU.getGPUs()
# XXX: only one GPU on Colab and isn’t guaranteed
gpu = GPUs[0]
def printm():
process = psutil.Process(os.getpid())
print("Gen RAM Free: " + humanize.naturalsize( psutil.virtual_memory().available ), " | Proc size: " + humanize.naturalsize( process.memory_info().rss))
print("GPU RAM Free: {0:.0f}MB | Used: {1:.0f}MB | Util {2:3.0f}% | Total {3:.0f}MB".format(gpu.memoryFree, gpu.memoryUsed, gpu.memoryUtil*100, gpu.memoryTotal))
printm()
from google.colab import drive
drive.mount("/content/gdrive")
# change to working tensorflow directory on the drive
%cd '/content/gdrive/My Drive/models/'
!apt-get install protobuf-compiler python-pil python-lxml python-tk
!pip install Cython
%cd '/content/gdrive/My Drive/models/research/'
#!protoc object_detection/protos/*.proto --python_out=.
import os
os.environ['PYTHONPATH'] += ':/content/gdrive/My Drive/models/research/:/content/gdrive/My Drive/models/research/slim'
!ls
!python setup.py build
!python setup.py install
import time, psutil
Start = time.time()- psutil.boot_time()
Left= 12*3600 - Start
print('Time remaining for this session is: ', Left/3600)
我在下面收到错误!
!pip install tf_slim
%cd /content/gdrive/My Drive/models/research/object_detection
os.environ['PYTHONPATH'] += ':/content/gdrive/My Drive/models/research/:/content/gdrive/My Drive/models/research/slim'
!python train.py --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_coco.config --logtostderr
%cd object_detection/
!pip install tf_slim
!python export_inference_graph.py --input_type image_tensor --pipeline_config_path training/ssd_mobilenet_v1_coco.config --trained_checkpoint_prefix training/model.ckpt-131906 --output_directory new_graph