ImportError: No module named 'yolo_utils' - python-3.5

I downloaded openCV and YOLO weights, in order to implement object detection for a certain project using Python 3.5 version.
when I run this code:
from yolo_utils import read_classes, read_anchors, generate_colors, preprocess_image, draw_boxes, scale_boxes
from yad2k.models.keras_yolo import yolo_head, yolo_boxes_to_corners, preprocess_true_boxes, yolo_loss, yolo_body
The console gives the error below:
ImportError Traceback (most recent call
last) in ()
----> 1 from yolo_utils import read_classes, read_anchors, generate_colors, preprocess_image, draw_boxes, scale_boxes
2 from yad2k.models.keras_yolo import yolo_head, yolo_boxes_to_corners, preprocess_true_boxes, yolo_loss, yolo_body
ImportError: No module named 'yolo_utils'
Note that i downloaded yolo_utils.py in the weights folder, how can I fix this issue?

Actually You are Importing user built module. As Yolo_utils is created by a Coursera coordinators to make things easy, this module is available in only their machines and You are trying to import this in your machine.
Here is github link of module :
https://github.com/JudasDie/deeplearning.ai/blob/master/Convolutional%20Neural%20Networks/week3/yolo_utils.py
Save this To your local machine in .py formet
And Copy this file in your lib files of Your application(anaconda or any other)

Copy the source code of yolo_utils .
Paste it in your source code before importing yolo_utils.
It worked for me.
Hope this will help..

Related

gRPC generated code for Python 3 not working

protoc was generating invalid code in Python 3.8. I found that it works in Python 3.6.
I followed the instructions as per: This fantastic blog
The command I ran was:
python -m grpc_tools.protoc --python_out=src/ --grpc_python_out=src/ --proto_path generated=./src/interfaces src/interfaces/ecg.proto
The first issue was the generated imports were not working. I changed the code as below, for the import to work, in pb2_grpc.py:
from . import ecg_pb2 as generated_dot_ecg__pb2
The imports were fine in Visual Code, but now the run-time error.
I have a couple of files in the "generated" folder. I also added an init.py into this folder that was supposed to expose the contents, as:
from .ecg_pb2 import *
from .ecg_pb2_grpc import *
At a peer level to this "generated" folder I have another file - server.py. I am trying to import "generated". It is only importing with a relative path: from .generated import ecg_pb2_grpc
However, while the import works with the relative path, the main in server.py is not getting invoked. Run time error -
(p36) C:\ECG\src>python ecg_server.py
Traceback (most recent call last):
File "ecg_server.py", line 6, in
from .generated import ecg_pb2
ModuleNotFoundError: No module named 'main.generated'; 'main' is not a package

ModuleNotFoundError: No module named '_pydevd_bundle'

Out of the blue I got the error listed below.
I am using Eclipse IDE and I have Python 2.7 and 3.6 installed (both WinPython)
I don't know when this started because I have worked for a while in 2.7. I just tried some code which I am writing in Jupyter and it is not working and I wanted to debug it easier in Eclipse. When I press the debug button I get the below
Traceback (most recent call last):
File "C:\Utils\PortableApps\PortableApps\Eclipse 4.6\plugins\org.python.pydev.core_7.0.3.201811082356\pysrc\pydevd.py", line 20, in <module>
from _pydevd_bundle.pydevd_constants import IS_JYTH_LESS25, IS_PYCHARM, get_thread_id, get_current_thread_id, \
ModuleNotFoundError: No module named '_pydevd_bundle'
It's absolutely due to that your files contain a dir named code! The name has conflicted with the system package. Just modify the dir name code to any name else. It should work well!

opencv import issue and double install

Previously ROS was installed in my system which requires opencv for its implementation and now I am using anaconda in which I need to use the opencv library once again. While writing python code import cv2 throws an error module not found.
Is there any way to use that opencv library which ROS installed in anaconda
Although I installed opencv once again using conda.
$conda install -c conda-forge opencv
however opencv-3.3 was installed using above command. Now my python code is showing different import error as shown below:
ImportError Traceback (most recent call last)
<ipython-input-9-6b49ad4d4ca5> in <module>()
1 from random import shuffle
2 import glob
----> 3 import cv2
4 shuffle_data = True # shuffle the addresses before saving
5 hdf5_path = 'dataset.hdf5' # address to where you want to save the hdf5 file
ImportError: /home/kamal/ros_catkin_ws/install_isolated/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type
How can I particularly specify which opencv library to use. What env variables I need to change.
Any help will be appreciated.
uncommenting the line source /home/user/ros_catkin_ws/install_isolated/share/setup.bash in the .bashrc file dosen't help. You also need to remove the extrasys.path added by the ROS environment.
In a python console
import sys
print (sys.path)
you will see multiple paths related to ROS
then remove the unwanted part of the path by
sys.path.remove('unwanted_path')
This will solve the problem but now ROS will not work. To make it work you need to append the removed path again.
If someone has a better approach please answer.

Error with import script in colaboratory

When I try to import a script that is in the same folder as the colaboratory
then I get an error:
ImportErrorTraceback (most recent call last)
<ipython-input-8-e7a4315427c8> in <module>()
----> 1 import translate
ImportError: No module named translate
The path and location of the file checked!!!
Colab doesn't automatically load any files from your Google Drive folder; you'll need to copy the files locally (eg with something like https://colab.research.google.com/notebooks/io.ipynb#scrollTo=P3KX0Sm0E2sF and then saving to a file).

Scikit Learn import error: 'cross_val_predict' is not defined

I am trying to run some simple codes of scikit-learn in python, and while executing this, I encountered this error:
from sklearn.cross_validation import cross_val_predict
Traceback (most recent call last):
File "", line 1, in
from sklearn.cross_validation import cross_val_predict
ImportError: cannot import name cross_val_predict
I have downloaded scikit learn from this page: http://sourceforge.net/projects/scikit-learn/?source=typ_redirect and the other modules like sklearn.linear_model works well. It seems that I can also import successfully the module cross_validation.. I cannot understand!
Yes ! It seems works now ! In fact, instead of using the .exe files that I downloaded from internet (which turned out to be perhaps incompatible), I finally successed to install many modules by the standard "pip install". The only thing that I could not use "pip install" is the package "Scipy", so I had to replace it by a .exe file. Thank you for all your help !

Resources