tensorspace-team / tensorspace

Neural network 3D visualization framework, build interactive and intuitive model in browsers, support pre-trained deep learning models from TensorFlow, Keras, TensorFlow.js
https://tensorspace.org
Apache License 2.0
5.06k stars 445 forks source link

ImportError: cannot import name 'convert_to_constants' #229

Closed hazily123 closed 5 years ago

hazily123 commented 5 years ago

在导入tensorflowjs的时候就会报这个错,在执行转换格式脚本的时候也是现实这个包导入有问题。

import tensorflowjs as tfjs Traceback (most recent call last): File "", line 1, in File "F:\anaconda\anaconda3\lib\site-packages\tensorflowjs-1.0.1-py3.6.egg\tensorflowjs__init.py", line 21, in from tensorflowjs import converters File "F:\anaconda\anaconda3\lib\site-packages\tensorflowjs-1.0.1-py3.6.egg\tensorflowjs\converters\init__.py", line 24, in from tensorflowjs.converters.tf_saved_model_conversion_v2 import convert_tf_saved_model File "F:\anaconda\anaconda3\lib\site-packages\tensorflowjs-1.0.1-py3.6.egg\tensorflowjs\converters\tf_saved_model_conversion_v2.py", line 29, in from tensorflow.python.framework import convert_to_constants ImportError: cannot import name 'convert_to_constants'

JordanMicahBennett commented 5 years ago

I figured out that the problem here, was that _convert_toconstants.py was missing from my python tensorflow framework directory.

This problem can easily be solved, by copying the convert_to_constants.py found on the official web-page's framework directory, into your Python36\Lib\site-packages\tensorflow\python\framework folder.

In your case, you would probably have to copy the file to your anaconda\lib\site-packages\tensorflowjs-1.0.1-py3.6.egg\tensorflowjs\ folder.

syt123450 commented 5 years ago

@hazily123 看起来像是 tensorflowjs 版本问题。对于模型预处理,可以试试最新发布的 TensorSpace 预处理工具 TensorSpace-Converter(使用这个工具来预处理,理论上不会遇到以上提到的 python 包版本问题),可以极大简化预处理过程。

hazily123 commented 5 years ago

我把文件放进去了文件夹,但是没有任何作用,还是会报那个错误。