import error of inception_utils on "tensorflow models learning" - python

I am using the inception model in https://github.com/Wnaner/tensorflow_models_nets.git, when I tried to run the file "inception_v3_train_val.py", an error occur:
Traceback (most recent call last):
File "inception_v3_train_val.py", line 8, in <module>
import slim.nets.inception_v3 as inception_v3
File "/Users/myname/Desktop/tensorflow_models_learning/slim/nets/inception_v3.py", line 23, in <module>
from nets import inception_utils
ImportError: cannot import name 'inception_utils' from 'nets' (/Users/myname/miniconda3/lib/python3.7/site-packages/nets/__init__.py)
but when i check the nets folder, it does have a inception_utils.py, now i don't know how to solve this problem, hope somebody can help. Thanks very much.

Related

Where can I find WidgetRedirector in with Python3?

I was using a tkform(https://github.com/boscoh/tkform) with Python2 and it was working perfectly.
After switching to Python3, Im unable to run it, specifically the part:
from idlelib.WidgetRedirector import WidgetRedirector
It seems that WidgetRedirecor.py not even in the library (idellib) anymore...
Traceback (most recent call last):
File "/Users/igor/opt/cymorph3/runCyMorphGUI.py", line 7, in <module>
import tkform
File "gui/tkform.py", line 22, in <module>
from idlelib import WidgetRedirector
ImportError: cannot import name 'WidgetRedirector' from 'idlelib' (/Users/igor/opt/anaconda3/envs/cyMorph3/lib/python3.9/idlelib/__init__.py)
Can I fix it somehow?
Use:
from idlelib.redirector import WidgetRedirector

How to fix ' ImportError: cannot import name 'numpy_type_map' ' in Python?

I've followed the instructions in Detectron and I've configured it several times: the code compiles as it should. When it comes to run the code, I get this error:
Traceback (most recent call last):
File "tools/train_net_step.py", line 21, in <module>
import nn as mynn
File "/home/federico/PycharmProjects/Detectron.pytorch/lib/nn/__init__.py", line 2, in <module>
from .parallel import DataParallel
File "/home/federico/PycharmProjects/Detectron.pytorch/lib/nn/parallel/__init__.py", line 3, in <module>
from .data_parallel import DataParallel, data_parallel
File "/home/federico/PycharmProjects/Detectron.pytorch/lib/nn/parallel/data_parallel.py", line 4, in <module>
from .scatter_gather import scatter_kwargs, gather
File "/home/federico/PycharmProjects/Detectron.pytorch/lib/nn/parallel/scatter_gather.py", line 8, in <module>
from torch.utils.data.dataloader import numpy_type_map
ImportError: cannot import name 'numpy_type_map'
I've also tried to google it many times, but I can't find a way to solve it. What can I do? I'm using PyTorch 0.4.1 and pytorch nightly 1.0.0-dev.
EDIT: Thanks to sancelot, I managed to solve that error (PyTorch 0.4.0 did the thing). Anyway, now I've got another error:
Traceback (most recent call last):
File "tools/train_net_step.py", line 27, in <module>
from modeling.model_builder import Generalized_RCNN
File "/home/federico/PycharmProjects/Detectron.pytorch/lib/modeling/model_builder.py", line 11, in <module>
from model.roi_pooling.functions.roi_pool import RoIPoolFunction
File "/home/federico/PycharmProjects/Detectron.pytorch/lib/model/roi_pooling/functions/roi_pool.py", line 3, in <module>
from .._ext import roi_pooling
File "/home/federico/PycharmProjects/Detectron.pytorch/lib/model/roi_pooling/_ext/roi_pooling/__init__.py", line 3, in <module>
from ._roi_pooling import lib as _lib, ffi as _ffi
ImportError: /home/federico/PycharmProjects/Detectron.pytorch/lib/model/roi_pooling/_ext/roi_pooling/_roi_pooling.so: undefined symbol: PyInt_FromLong
What I can't get this time is: is this an error given by an external library? I'm using an anaconda environment previously made by my professor, who has used it for Detectron... so I can't guess why I get this.
Yeah, these are due to Pytorch version mismatch. Solution depends on what extent you are willing to go, sometimes if you are okay with hacking and just getting it running, then just copy paste the numpy_type_map from older versions:
numpy_type_map = {
'float64': torch.DoubleTensor,
'float32': torch.FloatTensor,
'float16': torch.HalfTensor,
'int64': torch.LongTensor,
'int32': torch.IntTensor,
'int16': torch.ShortTensor,
'int8': torch.CharTensor,
'uint8': torch.ByteTensor,
}
Or, up to version 1.1.0, you can try replacing the import statement,
from:
from torch.utils.data.dataloader import numpy_type_map
to:
from torch.utils.data._utils.collate import numpy_type_map
N.b. will still break in more recent versions. Again, this is a hacky quick-fix solution.
I suppose there is a version mismatch between detectron and the needed pytorch release you are using.
if you look at latest pytorch source code, there is no numpy_type_map component.
https://github.com/pytorch/pytorch/blob/master/torch/utils/data/dataloader.py

problems about importing caffe

when I import caffe,it got some errors:
import caffe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/lili/caffe/1master/caffe-master/python/caffe/__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
File "/home/lili/caffe/1master/caffe-master/python/caffe/pycaffe.py", line 15, in <module>
import caffe.io
File "/home/lili/caffe/1master/caffe-master/python/caffe/io.py", line 8, in <module>
from caffe.proto import caffe_pb2
File "/home/lili/caffe/1master/caffe-master/python/caffe/proto/caffe_pb2.py", line 23, in <module>
\x06\x66iller\x18\x01 \x01(\x0b\x32\x16.caffe.FillerParameter\x12\x1d\n\x0e\x63hannel_shared\x18\x02 \x01(\x08:\x05\x66\x61lse*\x1c\n\x05Phase\x12\t\n\x05TRAIN\x10\x00\x12\x08\n\x04TEST\x10\x01')
TypeError: __init__() got an unexpected keyword argument 'syntax
who can help me?
Looks like there is some problem with the model prototype or the solver prototype you are using for training. Please make sure that the prototype files have only the defined attributes.
check your version of protobuf, it seems the version of protoc and python protobuf do not match

ImportError *.so: no suitable image found

I need to change the tempo of a song for a project and I would like to use the echonest's python library remix.
However, when I run, for example, the following command:
python beatshift.py "01 - I Saw Her Standing There.mp3" out.mp3
I get this error:
Traceback (most recent call last): File "beatshift.py", line 19, in
<module>
from echonest.remix import audio, modify File "build/bdist.macosx-10.6-x86_64/egg/echonest/remix/modify.py", line
11, in <module> File
"build/bdist.macosx-10.6-x86_64/egg/soundtouch.py", line 7, in
<module> File "build/bdist.macosx-10.6-x86_64/egg/soundtouch.py",
line 6, in bootstrap ImportError:
dlopen(/Users/JL/.python-eggs/remix-2.4.0-py2.7-macosx-10.6-x86_64.egg-tmp/soundtouch.so,
2): no suitable image found. Did find:
/Users/JL/.python-eggs/remix-2.4.0-py2.7-macosx-10.6-x86_64.egg-tmp/soundtouch.so:
mach-o, but wrong architecture
Do you know what can I do to solve it?

ImportError when using scipy.io

So I am having a bit of trouble using scipy. I have been importing data from a .mat file (matlab variables) and up until today it has worked perfectly. I have no idea what changed or when because I have been developing a text - based data format so that I can avoid depending on Matlab for writing my data. Anyways, I am getting a bizzare import error when I import scipy.io
import scipy.io
myData = scipy.io.loadmat('some_data_file')
When I run this I get the following error:
>>> import scipy.io
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\pyzo2014a\lib\site-packages\scipy\io\__init__.py", line 85, in <module>
from .matlab import loadmat, savemat, whosmat, byteordercodes
File "C:\pyzo2014a\lib\site-packages\scipy\io\matlab\__init__.py", line 13, in <module>
from .mio import loadmat, savemat, whosmat
File "C:\pyzo2014a\lib\site-packages\scipy\io\matlab\mio.py", line 13, in <module>
from .mio4 import MatFile4Reader, MatFile4Writer
File "C:\pyzo2014a\lib\site-packages\scipy\io\matlab\mio4.py", line 11, in <module>
import scipy.sparse
File "C:\pyzo2014a\lib\site-packages\scipy\sparse\__init__.py", line 217, in <module>
from .csgraph import cs_graph_components
File "C:\pyzo2014a\lib\site-packages\scipy\sparse\csgraph\__init__.py", line 148, in <module>
from ._shortest_path import shortest_path, floyd_warshall, dijkstra,\
ImportError: No module named 'scipy.sparse.csgraph._shortest_path'
I thought there might be something wrong with my python distribution so I reinstalled it, however the problem persists, and now the installer says it can't find '_shortest_path.py' when it is installing. When I navigate to .../Libs/site-packages/scipy/sparse/csgraph/ I find that indeed there is no module named _shortest_path. I don't understand how this error came about or how anything in my code would change it. Has anyone else come across this problem?
I am using Pyzo 2014 on Windows 7 x64.
Restore shortest_path.pyd in your virust chest
http://www.blendernation.com/2014/06/28/getting-a-virus-warning-with-blender-2-71-heres-why/

Categories