ModuleNotFoundError: No module named 'nets' for object detection api - python-3.x

I am trying to train TF object detection model on colab and I have added 'slim' to $PYTHONPATH
['/env/python',
'/content/gdrive/My\\ Drive/Real_Traffic_Vehicle_Detector/models/research',
'/content/gdrive/My\\ Drive/Real_Traffic_Vehicle_Detector/models/research/slim',
'/content/gdrive/My\\Drive/Real_Traffic_Vehicle_Detector/models/research/object_detection',
but even then when I try to run train.py file it shows error that no module named 'nets'. can anyone help me out?
WARNING:tensorflow: The TensorFlow contrib module will not be included
in TensorFlow 2.0. For more information, please see: *
https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
* https://github.com/tensorflow/addons * https://github.com/tensorflow/io (for I/O related ops) If you depend
on functionality not listed there, please file an issue.
Traceback (most recent call last): File "train.py", line 52, in
from object_detection.builders import model_builder File "/usr/local/lib/python3.6/dist-packages/object_detection/builders/model_builder.py",
line 35, in
from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res
File
"/usr/local/lib/python3.6/dist-packages/object_detection/models/faster_rcnn_inception_resnet_v2_feature_extractor.py",
line 28, in
from nets import inception_resnet_v2 ModuleNotFoundError: No module named 'nets'

You should change from
My\\ Drive
To just
My Drive
Because it is already in string quote.

Related

ModuleNotFoundError: No module named 'tensorflow.tools.graph_transforms' when using export_tflite_ssd_graph.py

I am trying to convert a saved_model from TensorFlow Object Detection Model Zoo to a tflite file. The model I am using is ssd_mobilenet_v2_oid_v4_2018_12_12.
So I used export_tflite_ssd_graph.py:
D:\TensorFlow\models\research\object_detection>python export_tflite_ssd_graph.py
--pipeline_config_path=D:\Models\ssd_mobilenet_v2_oid_v4_2018_12_12\pipeline.config
--trained_checkpoint_prefix=D:\Models\ssd_mobilenet_v2_oid_v4_2018_12_12\model.ckpt.data-00000-of-00001
--output_directory=D:\Models
--add_postprocessing_op=true
I get the following error
2020-01-20 19:43:36.765263: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-01-20 19:43:36.770058: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
File "export_tflite_ssd_graph.py", line 96, in <module>
from object_detection import export_tflite_ssd_graph_lib
File "C:\Users\Bhavin\AppData\Local\Programs\Python\Python36\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\export_tflite_ssd_graph_lib.py", line 26, in <module>
from tensorflow.tools.graph_transforms import TransformGraph
ModuleNotFoundError: No module named 'tensorflow.tools.graph_transforms'
I tried upgrading tensorflow with pip but I still get the same error.
I am using Windows 10 and TensorFlow 2.1.0.
Facing same problem.
Ad hoc fix is downgrade to tf 1.15.0

How to fix error :" AttributeError: module 'tensorflow' has no attribute 'contrib' " on Windows

I have a source code read CAPTCHA. When i run test, I got a problem on Windows 10
Traceback (most recent call last):
File "train.py", line 48, in <module>
from object_detection.builders import dataset_builder
File "C:\Users\HuyHys\Anaconda3\lib\site-packages\object_detection\builders\dataset_builder.py", line 27, in <module>
from object_detection.data_decoders import tf_example_decoder
File "C:\Users\HuyHys\Anaconda3\lib\site-packages\object_detection\data_decoders\tf_example_decoder.py", line 27, in <module>
slim_example_decoder = tf.contrib.slim.tfexample_decoder
AttributeError: module 'tensorflow' has no attribute 'contrib'
I found a ask on stackoverflow (visit Module 'tensorflow' has no attribute 'contrib')
But i can't fix this error. Pls, anyone can help me!
How to fix detail this error???
This Error occurs because tf.contrib is removed from TensorFlow 2. I guess you are using old code from Tensorflow 1 that is not compatible with the new Tenserflow 2. For more information checkout Migrate your TensorFlow 1 code to TensorFlow 2. If you need more help please share all code snippets where you use tf.contrib.

unable to run a python file because of Module not found error despite sourcing the pythonpath

I have been trying to run a python file using rosrun command but unfortunately I am having this module not found error because of a package named rospkg. Until a day before yesterday, it was all working fine but yesterday, ubuntu18.04 has got some updates out of which an update for ubuntu base was also present, since that update I am having this error.
I have tried to check whether I have installed the respective python-rospkg and its says I already have the latest version. I have also using
echo $PYTHONPATH
to check the sourced paths and they are sourced correct, I am not sure whats causing this error.
the error is as follows
Traceback (most recent call last
File
"/home/microbot/catkin_ws/src/spider/spider_control/control.py",
line 5, in <module>
import roslib
File "/opt/ros/melodic/lib/python2.7/dist-
packages/roslib/__init__.py", line 50, in <module>
from roslib.launcher import load_manifest
File "/opt/ros/melodic/lib/python2.7/dist-
packages/roslib/launcher.py", line 42, in <module>
import rospkg
ModuleNotFoundError: No module named 'rospkg'
The shebang for my is as follows,
#!/usr/bin/python3
When i try to run the file by changing the shebang to
#!/usr/bin/python2.7
I get the following error
Traceback (most recent call last):
File
"/home/microbot/catkin_ws/src/spider/spider_control/control.py",
line 3, in <module>
import tensorflow as tf
ImportError: No module named tensorflow
I have installed tensorflow version 1.14 using pip installation. Can anyone please help me solving this error. Thanks in advance
edit:
I have manually tried to set the python path to /usr/lib/python2.7/dist-packages as when I tried to install python-rospkg, it says the its already instaled in that location. Doing that I am having error importing tensorflow and the error is
`Traceback (most recent call last):
File
"/home/microbot/catkin_ws/src/spider/spider_control/control.py", line
3, in <module>
import tensorflow as tf
File "/home/microbot/.local/lib/python3.6/site-
packages/tensorflow/__init__.py", line 22, in <module>
import inspect as _inspect
File "/usr/lib/python3.6/inspect.py", line 41, in <module>
import linecache
File "/usr/lib/python3.6/linecache.py", line 11, in <module>
import tokenize
File "/usr/lib/python3.6/tokenize.py", line 33, in <module>
import re
File "/usr/lib/python3.6/re.py", line 142, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
Error in sys.excepthook:`

Yaml with Python 3

I have a python3.6 virtual environment. I an trying to run some keras code and came across this error:
Traceback (most recent call last):
File "test.py", line 4, in <module>
from keras import backend as K
File "Keras-2.0.8/keras/__init__.py", line 4, in <module>
from . import activations
File "Keras-2.0.8/keras/activations.py", line 6, in <module>
from .engine import Layer
File "Keras-2.0.8/keras/engine/__init__.py", line 3, in <module>
from .topology import InputSpec
File "Keras-2.0.8/keras/engine/topology.py", line 8, in <module>
import yaml
File "Keras-2.0.8/yaml/__init__.py", line 2, in <module>
from error import *
ModuleNotFoundError: No module named 'error'
I saw a few other posts regarding this but those all suggest that the problems may be that I am using the python 2.7 version for python3. However, I don not think this is the case since I am in a python 3.6 virtual environment.
I also saw some comments about re-installing/upgrading yaml with python3.6 specifically. I thought doing a pip install in the virtual environment would fix this but it did not seem to help. Any suggestions regarding how to resolve this issue would be much appreciated.
Side Note: the code I am trying to run is test.py from this repo when I come across the error.

Can't import cv2 in Python 2.7 linux

I'm trying to get OpenDroneMap to run on my linux mint machine. I've been working my way through a number of problems in the current release's dependency chain.
At the moment, I'm stumped on getting the OpenCV module, cv2 to import.
OpenCV is required by an OpenDroneMap dependency, OpenSfM and it's one of the OpenSfM py files that tries to import the module cv2.
Anyway, running OpenDroneMap generates the error:
Traceback (most recent call last):
File "~/OpenDroneMap/src/OpenSfM/bin/opensfm", line 10, in <module>
from opensfm import commands
File "~/OpenDroneMap/src/OpenSfM/opensfm/commands/__init__.py", line 3, in <module>
import extract_metadata
File "~/OpenDroneMap/src/OpenSfM/opensfm/commands/extract_metadata.py", line 5, in <module>
from opensfm import dataset
File "~/OpenDroneMap/src/OpenSfM/opensfm/dataset.py", line 12, in <module>
import cv2
ImportError: dynamic module does not define init function (PyInit_cv2)
b
quitting cause:
PYTHONPATH=~/OpenDroneMap/lib/python2.7/dist-packages "~/OpenDroneMap/src/OpenSfM/bin/run_all" opensfm
returned with code 256.
From what I can tell, the import error cause typically suggests that the cv2 module was not found. I've ensured that cv2.so does exist in the path specified, as well as the usr/lib/python27/dist-packages path, where it seems to me it should really be looking...
In any case, I was hoping someone might be able to give me some direction on what to try next.

Resources