I started to learn object detection with TensorFlow from this tutorial but have some problems with trainer import module.
I've downloaded Tensorflow models and protoc-3.4.0-win32 and already compiled object_detection\protos for Python, also prepared images with labels and set enviroment variables.
Now everything is fine but an error occurs while running 3_train.py script from this repo:
File "C:\Users\Username\Desktop\TensorFlow\TensorFlow_Tut_3_Object_Detection_Walk-through-master\3_train.py", line 11, in <module>
from object_detection import trainer
ImportError: cannot import name 'trainer'
I don't know how to fix this error. I'am using Python 3.6.6 on Win7x64.
Any advice will be appreciated!
I think you have to clone the github repo for tensorflow object detection models. https://github.com/tensorflow/models. 3_train.py needs object_detection/trainer.py.
Best regards.
Related
I am trying to play around with a custom object detection model that builds of a pretrained model. All I want is for my model is to detect a specific logo in a picture. The problem is, the guide that I am following is having problems with the libraries.
import tensorflow as tf
from imageai.Detection.Custom import DetectionModelTrainer
trainer = DetectionModelTrainer()
trainer.setModelTypeAsYOLOv3()
trainer.setDataDirectory(data_directory="/content/drive/MyDrive/Logo_Model2/")
trainer.setTrainConfig(object_names_array=["logo"], batch_size=4, num_experiments=122, train_from_pretrained_model="/content/drive/MyDrive/pretrained-yolov3.h5")
trainer.trainModel()
My error is coming when I import imageai.Detection.Custom import DetectionModelTrainer. I am doing this on google colab and I checked the versions and they seem to be all up to date.
ModuleNotFoundError: No module named 'tensorflow.keras'
Any ideas? I have looked around stack for similar problems yet I haven't been able to resolve my issue. It doesn't seem to be a tensorflow problem since I am able to build my models just fine until I add imageai.
Seems to be an issue with the latest tensorflow==2.8.0. git issue
For now, you can revert back to the older version of tensorflow
pip install tensorflow==2.7
And upgrade imageAI :
pip install imageai --upgrade
I have tried to train Deepspeech model on Windows, as I can not use Linux. But, I am not able to train I am getting error
File "E:/deepspeech-german-master/DeepSpeech/training/deepspeech_training/train.py", line 30, in <module>
from DeepSpeech.native_client.ctcdecode import ctc_beam_search_decoder, Scorer
File "E:\deepspeech-german-master\DeepSpeech\native_client\ctcdecode\__init__.py", line 3, in <module>
from . import swigwrapper # pylint: disable=import-self
ImportError: cannot import name 'swigwrapper' from 'DeepSpeech.native_client.ctcdecode' (E:\deepspeech-german-master\DeepSpeech\native_client\ctcdecode\__init__.py)```
I installed Kenlm language model using cygwin. But I am not able to train. If anybody has used it on windows. Can you please help, I am stuck on this since back so many days.
Swig is a build and packaging tool. It is not pre-built for Windows which is why you are receiving the swigwrapper error. You can read more about running Swig on Windows here.
A much better approach to running DeepSpeech on Windows is to install Docker, and use a Docker environment for training. This removes a lot of the dependency issues you are facing. This is documented in the DeepSpeech PlayBook.
I have been getting multiple errors which are due to conflicts in the TensorFlow version installed in my system and the version used to write the code in Tensorflow API.
I am using python 3.6.7 and Tensorflow 2.0 to get started with the code https://github.com/tensorflow/models/blob/master/research/deeplab/g3doc/installation.md
But I am getting several errors :
flags = tf.app.flags
AttributeError: module 'tensorflow' has no attribute 'app.
As I am using 2.0 , I replaced tf.app.flags with tf.compat.v1.flags.
from tensorflow.contrib import slim as contrib_slim
ModuleNotFoundError: No module named 'tensorflow.contrib'
I am not able to solve the second one.
Can I get help to know which python and tensorflow version should be used to run DeepLab v3+?
You should use the Tensorflow version 1.x to run the DeepLabV3+ model because it uses a session to run and also the slim library which is based on the TensorFlow 1.x. And so your two problems can be solved as:
Do not need to replace tf.app.flags with tf.compat.v1.flags.
To run DeepLabV3+ model, you need to put deeplab and slim folder in a folder (deeplab_slim),
and export them by running following export commands from this parent folder (deeplab_slim):
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/deeplab
I have attempted to install Tensorflow on Ubuntu 18.04 by following this installation guide from the Tensorflow website. However, after importing tensorflow in python/jupyter notebook, none of the functionality appears to be working.
For example if I run:
#import tensorflow
import tensorflow as tf
#initialize two constants
x1 = tf.constant([1,2,3,4])
x2 = tf.constant([5,6,7,8])
I get the following error:
AttributeError: module 'tensorflow' has no attribute 'constant'
Does anyone know why this attribute is unavailable? on the tensorflow website it should be still be a fully functional command.
This is my first time attempting to run tensorflow so any help on the topic would be greatly appreciated!
You have to change your folder name to something else except tensorflow.
The reason is when you use import x python first searches for a folder named x and imports __init__.py file inside it. In your case you don't have that file with predefined constant in it and above that you want the tensorflow itself!
I had the same error. After I installed tensorflow-eigen the problem is solved.
Using Python 2.7 (miniconda) and trying to run below example, but it is said Unresolved reference to example_parser_configuration_pb2, does anyone have any solutions?
BTW, my machine is configured with tensorflow and I can run some tensorflow examples, so tensorflow basic configuration should be ok.
from tensorflow.core.example import example_parser_configuration_pb2
https://github.com/tensorflow/tensorflow/blob/754048a0453a04a761e112ae5d99c149eb9910dd/tensorflow/python/util/example_parser_configuration_test.py#L70
regards,
Lin