首页 > 解决方案 > 运行样式转换代码时出现 Cmd 错误

问题描述

我尝试将此 GitHub 存储库中经过训练的样式转移代码应用于我拥有的图像:https ://github.com/lengstrom/fast-style-transfer

我在 Windows 10 cmd 中运行了这些命令:

conda create -n style-transfer python=3

conda activate style-transfer

conda install tensorflow scipy pillow

pip install moviepy

pip install imageio-ffmpeg

然后这个命令应该给我我的风格转移图像:

python evaluate.py --checkpoint ./rain-princess.ckpt --in-path 
C:\Users\hp\Downloads\fast-style-transfer-master\fast-style-transfer- 
master\download.jpg --out-path ./output_image.jpg

错误报告(在 Ctrl+C 挂起 cmd 之后):

Traceback (most recent call last):
  File "evaluate.py", line 4, in <module>
    import transform, numpy as np, vgg, pdb, os
  File "src\transform.py", line 1, in <module>
    import tensorflow as tf, pdb
  File "C:\Users\hp\Anaconda3\envs\style-transfer\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
    from tensorflow._api.v1 import compat
  File "C:\Users\hp\Anaconda3\envs\style-transfer\lib\site-packages\tensorflow\_api\v1\compat\__init__.py", line 21, in <module>
    from tensorflow._api.v1.compat import v1
  File "C:\Users\hp\Anaconda3\envs\style-transfer\lib\site-packages\tensorflow\_api\v1\compat\v1\__init__.py", line 649, in <module>
    from tensorflow_estimator.python.estimator.api._v1 import estimator
  File "C:\Users\hp\Anaconda3\envs\style-transfer\lib\site-packages\tensorflow_estimator\python\estimator\api\__init__.py", line 8, in <module>
    from tensorflow_estimator.python.estimator.api._v1 import estimator
  File "C:\Users\hp\Anaconda3\envs\style-transfer\lib\site-packages\tensorflow_estimator\python\estimator\api\_v1\estimator\__init__.py", line 9, in <module>
    from tensorflow_estimator.python.estimator.api._v1.estimator import export
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 724, in exec_module
  File "<frozen importlib._bootstrap_external>", line 818, in get_code
  File "<frozen importlib._bootstrap_external>", line 917, in get_data
  KeyboardInterrupt

最初,当我尝试运行 python 命令时,src 文件夹中 utils.py 文件的第 16 行有一个 AttributeError(imread),我可以通过将 scipy 弃用到 1.1.0 来解决这个问题。然后使用 v1 属性的 tensorflow 错误开始一个接一个地弹出。然后我卸载并重新安装了 tensorflow。然后它给了我一个错误报告,指出程序的操作无法在我拥有的资源上完成。

所以我删除了那个环境并重新重复了整个过程。现在这是我得到的错误报告。任何帮助都会很棒。

编辑:尝试运行命令再次执行程序。然后出现了带有 imread 的 AttributeError 。所以我不推荐使用 scipy :

pip install scipy==1.1.0

然后当我尝试执行时,这是出现的错误报告。它在循环中不断地打印错误(一次又一次的相同内容):

OMP: Info #212: KMP_AFFINITY: decoding x2APIC ids.
OMP: Info #210: KMP_AFFINITY: Affinity capable, using global cpuid leaf 11 info
OMP: Info #154: KMP_AFFINITY: Initial OS proc set respected: 0-7
OMP: Info #156: KMP_AFFINITY: 8 available OS procs
OMP: Info #157: KMP_AFFINITY: Uniform topology
OMP: Info #179: KMP_AFFINITY: 1 packages x 4 cores/pkg x 2 threads/core (4 total cores)
OMP: Info #214: KMP_AFFINITY: OS proc to physical thread map:
OMP: Info #171: KMP_AFFINITY: OS proc 0 maps to package 0 core 0 thread 0
OMP: Info #171: KMP_AFFINITY: OS proc 1 maps to package 0 core 0 thread 1
OMP: Info #171: KMP_AFFINITY: OS proc 2 maps to package 0 core 1 thread 0
OMP: Info #171: KMP_AFFINITY: OS proc 3 maps to package 0 core 1 thread 1
OMP: Info #171: KMP_AFFINITY: OS proc 4 maps to package 0 core 2 thread 0
OMP: Info #171: KMP_AFFINITY: OS proc 5 maps to package 0 core 2 thread 1
OMP: Info #171: KMP_AFFINITY: OS proc 6 maps to package 0 core 3 thread 0
OMP: Info #171: KMP_AFFINITY: OS proc 7 maps to package 0 core 3 thread 1
OMP: Info #250: KMP_AFFINITY: pid 1008 tid 11960 thread 0 bound to OS proc set 0
OMP: Info #250: KMP_AFFINITY: pid 1008 tid 10360 thread 1 bound to OS proc set 2
OMP: Info #250: KMP_AFFINITY: pid 1008 tid 3516 thread 2 bound to OS proc set 4
OMP: Info #250: KMP_AFFINITY: pid 1008 tid 1984 thread 3 bound to OS proc set 6
WARNING:tensorflow:From evaluate.py:85: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead.

WARNING:tensorflow:From evaluate.py:88: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

2019-10-13 19:44:56.652411: I tensorflow/core/platform/cpu_feature_guard.cc:145] This TensorFlow binary is optimized with Intel(R) MKL-DNN to use the following CPU instructions in performance critical operations:  AVX AVX2
To enable them in non-MKL-DNN operations, rebuild TensorFlow with the appropriate compiler flags.
2019-10-13 19:44:56.678997: I tensorflow/core/common_runtime/process_util.cc:115] Creating new thread pool with default inter op setting: 8. Tune using inter_op_parallelism_threads for best performance.
WARNING:tensorflow:From evaluate.py:90: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

WARNING:tensorflow:From src\transform.py:66: The name tf.truncated_normal is deprecated. Please use tf.random.truncated_normal instead.

WARNING:tensorflow:From evaluate.py:94: The name tf.train.Saver is deprecated. Please use tf.compat.v1.train.Saver instead.

WARNING:tensorflow:From C:\Users\hp\Anaconda3\envs\style-transfer\lib\site-packages\tensorflow\python\training\saver.py:1276: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.
Instructions for updating:
Use standard file APIs to check for files with this prefix.
2019-10-13 19:45:15.381542: W tensorflow/core/common_runtime/colocation_graph.cc:1016] Failed to place the graph without changing the devices of some resources. Some of the operations (that had to be colocated with resource generating operations) are not supported on the resources' devices. Current candidate devices are [
  /job:localhost/replica:0/task:0/device:CPU:0].
See below for details of this colocation group:
Colocation Debug Info:
Colocation group had the following types and supported devices:
Root Member(assigned_device_name_index_=-1 requested_device_name_='/device:GPU:0' assigned_device_name_='' resource_device_name_='/device:GPU:0' supported_device_types_=[CPU] possible_devices_=[]
VariableV2: CPU
Assign: CPU
Identity: CPU

Colocation members, user-requested devices, and framework assigned devices, if any:
  Variable (VariableV2) /device:GPU:0
  Variable/Assign (Assign) /device:GPU:0
  Variable/read (Identity) /device:GPU:0
  save/Assign (Assign) /device:GPU:0

如果有人可以帮助我找出问题所在,我将不胜感激。

标签: pythontensorflowdeep-learning

解决方案


推荐阅读