ImportError: No module named inception - tensorflow

Im using imagenet train script (https://github.com/tensorflow/models/blob/master/inception/inception/imagenet_train.py) to train my own image data set to classify in tensorflow (in Oracle VM Virtual box) and im getting an error as below
shri#shri-VirtualBox:~/Desktop/Test/inception_test/models/inception/inception$ python imagenet_train.py
Traceback (most recent call last):
File "imagenet_train.py", line 25, in
from inception import inception_train
ImportError: No module named inception
Could someone please help understand the problem and how do i fix it?
Regards,
Shri

This sounds like a Python module search path issue. The import statements in the particular script imagenet_train.py and other scripts in that directory assume that they can find the other scripts in a submodule called inception, but when you run the script from the same directory, Python can't find that submodule.
The easiest way to fix this is to change to the parent directory (cd ~/Desktop/Test/inception_test/models/inception) and run the script as follows:
$ python inception/inception_train.py

Related

No module named tenserflow

i came to this problem when im about to generate tfrecord for my test and training data. can anyone help me?
C:\Object_detection\models-master\research\object_detection>python generate_tfrecord.py --csv_input=images/test_labels.csv --image_dir=images/test --output_path=test.record
Traceback (most recent call last):
File "generate_tfrecord.py", line 17, in
from tensorflow.python.framework.versions import VERSION
ModuleNotFoundError: No module named 'tensorflow'
I am really stuck lol. Thank you for the help!
Try to run
pip show tensorflow
to check you tensorflow version.
It's possible that you will need to downgrade or upgrade you tf package to be able to run your tfrecord. Check the documentation of the function to know the version you need.

ImportError: cannot import name 'preprocessor_pb2' in the training part after installation was successful

I installed the object detection API correctly using this https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md and I checked by running model_builder_test.py
This gave me a OK result.
Then I moved on to running the train.py on my dataset using the following command
python train.py --logtostderr --pipeline_config_path=pipeline.config --train_dir=train_file
And I am getting the error ImportError: cannot import name 'preprocessor_pb2'
This particular preprocessor_pb2.py exists in the path it is looking for i.e
C:\Users\SP-TestMc\Anaconda3\envs\tensorflow\models-master\models-master\research\object_detection\protos
What could be the reason for this error then?
See https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md#protobuf-compilation. Sounds like you need to compile the protos before using the Python scripts.

Anaconda install of Tensorflow missing 'audio_ops' from contrib framework

I'm trying to follow along the Audio Recognition Network tutorial.
I've created an Anaconda environment with python 3.6 and followed the install instruction accordingly for installing the GPU whl.
I can run the 'hello world' TF example.
When I go to run 'train.py' in the Audio Recognition Network tutorial/example, I get:
Traceback (most recent call last):
File "train.py", line 79, in <module>
import input_data
File "/home/philglau/speech_commands/input_data.py", line 35, in <module>
from tensorflow.contrib.framework.python.ops import audio_ops as contrib_audio
ImportError: cannot import name 'audio_ops'
The code in the tutorial that fails is:
from tensorflow.contrib.framework.python.ops import audio_ops as contrib_audio
I then backed up that chain until I could import some part of it:
import tensorflow.contrib.framework as test ==> works
import tensorflow.contrib.framework.python as test --> fail:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'tensorflow.contrib.framework' has no attribute 'python'
Not sure where I'm going wrong on my install.
Details:
Ubuntu 16.04
Anaconda env with python 3.6
Followed the 'anaconda' instruction on the TF install page. (GPU version)
I also tried using a python 2.7 env for anaconda but got the same results.
It looks like they're releasing the audio_ops modules in version 1.4 (https://github.com/tensorflow/tensorflow/issues/11339#issuecomment-327879009).
Until v1.4 is released, an easy way around this is to install the nightly tensorflow build
pip install tf-nightly
or with the docker image linked in the issue comment.
The short answer:
The framework is missing the "audio_ops.py" and the example wont work until the file is released. Or you code the wrappers.
More on this:
If you go to the: tensorflow.contrib.framework.python.ops local folder you can find other *_ops.py files but not the "audio_ops.py".
If you get it from the Master at: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/framework/python/ops
You will find the file is almost empty and with import labels wrong: "audio_ops" vs "gen_audio_ops".
With almost empty I mean that: decode_wav, encode_wav, audio_spectrogram , mfcc are not implemented/wrapped.
So, no working example and no fun.
We need to check again when "audio_ops.py" is released.
Here:
https://github.com/tensorflow/tensorflow/issues/11339
You can find a Developer saying: "we don't actually want to make them public / supported yet. I'm sorry this decision wasn't better documented"

unittest in tensorflow, python session_test.py, got a exception

I'm trying to run session_test.py from https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/client/session_test.py, So in my anaconda, tensorflow virtual env, I went to the corresponding directory in tensorflow like ../master/tensorflow/python/client/.. and run
python session_test.py
I got exception info like this:
Traceback (most recent call last):
File "session_test.py", line 32, in
from tensorflow.core.protobuf import cluster_pb2
ImportError: cannot import name 'cluster_pb2'
What package I should install or related documents that I could read about it. Is there anyone trying to do the same thing, run those unit test coming along with each module in tensorflow repo?
Please help me, thanks!
That line was added just a couple of weeks ago (see commit), and relates to a new feature being implemented in TensorFlow. Unless you have compiled and installed a very bleeding-edge version of TensorFlow you won't be able to run it. Instead, try to run the script corresponding to the version of TensorFlow that you have installed (for example, this is for version 1.1.0, the latest stable release at the time of writing).

No module named numpy when spark-submitting

I’m spark-submitting a python file that imports numpy but I’m getting a no module named numpy error.
$ spark-submit --py-files projects/other_requirements.egg projects/jobs/my_numpy_als.py
Traceback (most recent call last):
File "/usr/local/www/my_numpy_als.py", line 13, in <module>
from pyspark.mllib.recommendation import ALS
File "/usr/lib/spark/python/pyspark/mllib/__init__.py", line 24, in <module>
import numpy
ImportError: No module named numpy
I was thinking I would pull in an egg for numpy —python-files, but I'm having trouble figuring out how to build that egg. But then it occurred to me that pyspark itself uses numpy. It would be silly to pull in my own version of numpy.
Any idea on the appropriate thing to do here?
It looks like Spark is using a version of Python that does not have numpy installed. It could be because you are working inside a virtual environment.
Try this:
# The following is for specifying a Python version for PySpark. Here we
# use the currently calling Python version.
# This is handy for when we are using a virtualenv, for example, because
# otherwise Spark would choose the default system Python version.
os.environ['PYSPARK_PYTHON'] = sys.executable
I got this to work by installing numpy on all the emr-nodes by configuring a small bootstrapping script that contains the following (among other things).
#!/bin/bash -xe
sudo yum install python-numpy python-scipy -y
Then configure the bootstrap script to be executed when you start your cluster by adding the following option to the aws emr command (the following example gives an argument to the bootstrap script)
--bootstrap-actions Path=s3://some-bucket/keylocation/bootstrap.sh,Name=setup_dependencies,Args=[s3://some-bucket]
This can be used when setting up a cluster automatically from DataPipeline as well.
Sometimes, when you import certain libraries, your namespace is polluted with numpy functions. Functions such as min, max and sum are especially prone to this pollution. Whenever in doubt, locate calls to these functions and replace these calls with __builtin__.sum etc. Doing so will sometimes be faster than locating the pollution source.
Make sure your spark-env.sh has PYSPARK_PATH pointing to the correct Python release. Add export PYSPARK_PATH=/your_python_exe_path to /conf/spark-env.sh file.