akosiorek / hart

Hierarchical Attentive Recurrent Tracking
GNU General Public License v3.0
146 stars 49 forks source link

demo.ipynb import issues #4

Open IdoWSC opened 6 years ago

IdoWSC commented 6 years ago

Hi, I have a problem running the demo: ImportError Traceback (most recent call last)

in () 7 8 from hart.data import disp ----> 9 from hart.data.kitti.tools import get_data 10 from hart.model import util 11 from hart.model.attention_ops import FixedStdAttention C:\Program Files\Anaconda3\Lib\site-packages\hart\hart\data\kitti\tools.py in () 26 import tensorflow as tf 27 ---> 28 import neurocity as nct 29 from neurocity.data import store 30 from neurocity.data import tools as data_tools C:\Program Files\Anaconda3\Lib\site-packages\hart\neurocity\__init__.py in () 20 ######################################################################################## 21 ---> 22 from component.model.base import train_mode, test_mode, mode 23 from component import loss, layer 24 from component.model.model import Model C:\Program Files\Anaconda3\Lib\site-packages\hart\neurocity\component\__init__.py in () 23 24 import tensorflow as tf ---> 25 from layer import Layer 26 from model.model import Model 27 C:\Program Files\Anaconda3\Lib\site-packages\hart\neurocity\component\layer.py in () 26 import numpy as np 27 ---> 28 from neurocity.component.model import base 29 30 C:\Program Files\Anaconda3\Lib\site-packages\hart\neurocity\component\__init__.py in () 23 24 import tensorflow as tf ---> 25 from layer import Layer 26 from model.model import Model 27 ImportError: cannot import name 'Layer'
akosiorek commented 6 years ago

The class Layer is defined in neurocity.component.layer (at https://github.com/akosiorek/hart/blob/master/neurocity/component/layer.py) I assume the error has to do with how environment variables are set on your system. Can you try adding the hart folder to your PYTHONPATH?

IdoWSC commented 6 years ago

Thx Adam, I have hart, neurocity, and component all added to PYTHONPATH. I also check layer.py and saw that in fact Layer is defined there. I'll need to check why does this problem occur.

By the way, has the script ever run on Windows and/or Python3+?

akosiorek commented 6 years ago

I have hart, neurocity, and component all added to PYTHONPATH

I have only hart in my PYTHONPATH; that might be the issue.

By the way, has the script ever run on Windows and/or Python3+?

I tested only on MacOS and Linux and Python 2.7

IdoWSC commented 6 years ago

I think I found the source of the issue. File "C:\Program Files\Anaconda3\Lib\site-packages\hart\hart\model\attention_ops.py", line 28, in from hart.model import tensor_ops File "C:\Program Files\Anaconda3\Lib\site-packages\hart\hart\model\tensor_ops.py", line 23, in from neurocity.tensor_ops import broadcast_against File "C:\Program Files\Anaconda3\Lib\site-packages\hart\neurocity__init.py", line 22, in from component.model.base import train_mode, test_mode, mode File "C:\Program Files\Anaconda3\Lib\site-packages\hart\neurocity\component\init.py", line 25, in from layer import Layer File "C:\Program Files\Anaconda3\Lib\site-packages\hart\neurocity\component\layer.py", line 28, in from neurocity.component.model import base File "C:\Program Files\Anaconda3\Lib\site-packages\hart\neurocity\component\init__.py", line 25, in from layer import Layer ImportError: cannot import name 'Layer'

in hart\neurocity__init.py there is an import from component.model.base which first runs component/init__.py.

There there is an import from layer which runs component/model/init.py that calls for import from component.model.model base that is importing layer again that eventually imports base again and so on.

this infinite loop is whats causing this failure

IdoWSC commented 6 years ago

The source for the issue when using Python3.3+ can be found here: import_traps

IdoWSC commented 6 years ago

I have modified your package to comply with py3.3+ and tf1.3+ if it interests you guys contact me

akosiorek commented 6 years ago

Good job @IdoWSC. Sure, it'd be great to have. Would you like to submit a PR?

ghost commented 5 years ago

I run demo.ipynb,but I do not found result picture.

ghost commented 5 years ago

why not use plt.show()? I can not to show the picture.