Tensorflow Object Detection Training Error - python-3.x

I am following tutorial for Tensorflow Object Detection
link
and getting the following command when i try this command
python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config
error:
FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
Traceback (most recent call last):
File "train.py", line 49, in <module>
from object_detection import trainer
File "C:\Users\ASUS PC\Anaconda3\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\trainer.py", line 32, in <module>
from object_detection.utils import variables_helper
File "C:\Users\ASUS PC\Anaconda3\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\utils\variables_helper.py", line 23, in <module>
slim = tf.contrib.slim
File "C:\Users\ASUS PC\Anaconda3\lib\site-packages\tensorflow\python\util\lazy_loader.py", line 53, in __getattr__
module = self._load()
File "C:\Users\ASUS PC\Anaconda3\lib\site-packages\tensorflow\python\util\lazy_loader.py", line 42, in _load
module = importlib.import_module(self.__name__)
File "C:\Users\ASUS PC\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\ASUS PC\Anaconda3\lib\site-packages\tensorflow\contrib\__init__.py", line 37, in <module>
from tensorflow.contrib import distributions
File "C:\Users\ASUS PC\Anaconda3\lib\site-packages\tensorflow\contrib\distributions\__init__.py", line 39, in <module>
from tensorflow.contrib.distributions.python.ops.estimator import *
File "C:\Users\ASUS PC\Anaconda3\lib\site-packages\tensorflow\contrib\distributions\python\ops\estimator.py", line 21, in <module>
from tensorflow.contrib.learn.python.learn.estimators.head import _compute_weighted_loss
File "C:\Users\ASUS PC\Anaconda3\lib\site-packages\tensorflow\contrib\learn\__init__.py", line 95, in <module>
from tensorflow.contrib.learn.python.learn import *
File "C:\Users\ASUS PC\Anaconda3\lib\site-packages\tensorflow\contrib\learn\python\__init__.py", line 28, in <module>
from tensorflow.contrib.learn.python.learn import *
File "C:\Users\ASUS PC\Anaconda3\lib\site-packages\tensorflow\contrib\learn\python\learn\__init__.py", line 40, in <module>
from tensorflow.contrib.learn.python.learn.experiment import Experiment
File "C:\Users\ASUS PC\Anaconda3\lib\site-packages\tensorflow\contrib\learn\python\learn\experiment.py", line 39, in <module>
from tensorflow.contrib.tpu.python.tpu import tpu_estimator
File "C:\Users\ASUS PC\Anaconda3\lib\site-packages\tensorflow\contrib\tpu\__init__.py", line 54, in <module>
from tensorflow.contrib.tpu.python import profiler
File "C:\Users\ASUS PC\Anaconda3\lib\site-packages\tensorflow\contrib\tpu\python\profiler\__init__.py", line 23, in <module>
from tensorflow.contrib.tpu.profiler.tpu_profiler_analysis_pb2 import *
File "C:\Users\ASUS PC\Anaconda3\lib\site-packages\tensorflow\contrib\tpu\profiler\tpu_profiler_analysis_pb2.py", line 16, in <module>
from tensorflow.contrib.tpu.profiler import tpu_profiler_pb2 as tensorflow_dot_contrib_dot_tpu_dot_profiler_dot_tpu__profiler__pb2
File "C:\Users\ASUS PC\Anaconda3\lib\site-packages\tensorflow\contrib\tpu\profiler\tpu_profiler_pb2.py", line 395, in <module>
_sym_db.RegisterServiceDescriptor(_TPUPROFILER)
AttributeError: 'SymbolDatabase' object has no attribute 'RegisterServiceDescriptor'
anybody faced this types of error? If so how can i solve the problem?

I is definitely related to something being off in your setup.py. Here is a thread that may help: https://github.com/GoogleCloudPlatform/cloudml-samples/issues/146. You may need to specify the version of the packages you are using as well.

link
In here the same issue is discussed and they found a solution. The problem is protobuf version i think.

Related

Cannot import pyrebase GAE

I have an application which works perfectly locally. But, for some reason, in GAE (standard python37) it seems to have an issue importing pyrebase (pyrebase==3.0.27 in requirements.txt). Any idea how to fix this?
Thanks in advance!
Traceback (most recent call last):
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
self.load_wsgi()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
self.wsgi = self.app.wsgi()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
return self.load_wsgiapp()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
return util.import_app(self.app_uri)
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
__import__(module)
File "/workspace/main.py", line 8, in <module>
import pyrebase
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/pyrebase/__init__.py", line 1, in <module>
from .pyrebase import initialize_app
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/pyrebase/pyrebase.py", line 17, in <module>
from oauth2client.service_account import ServiceAccountCredentials
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/oauth2client/service_account.py", line 25, in <module>
from oauth2client import client
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/oauth2client/client.py", line 47, in <module>
from oauth2client import crypt
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/oauth2client/crypt.py", line 55, in <module>
from oauth2client import _pycrypto_crypt
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/oauth2client/_pycrypto_crypt.py", line 17, in <module>
from Crypto.PublicKey import RSA
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/Crypto/PublicKey/__init__.py", line 29, in <module>
from Crypto.Util.asn1 import (DerSequence, DerInteger, DerBitString,
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/Crypto/Util/asn1.py", line 33, in <module>
from Crypto.Util.number import long_to_bytes, bytes_to_long
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/Crypto/Util/number.py", line 398
s = pack('>I', n & 0xffffffffL) + s
SyntaxError: invalid syntax
Pyrebase 3.0.27 is having compatibility issue with Python version 3. Instead, use the latest version of Pyrebase: Pyrebase4.
The OP solved the problem by changing Pyrebase version in requirements.txt:
From pyrebase==3.0.27 to Pyrebase4==4.5.0

AttributeError: module 'tensorflow._api.v1.initializers' has no attribute 'TruncatedNormal'

I get the following error when I try to import sentence_transformers in python 3.6.7 and tensorflow==2.3.0. Can someone please help me with this? Seems like it's a bug in the transformers package.
import sentence_transformers
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/__init__.py", line 3, in <module>
from .datasets import SentencesDataset, SentenceLabelDataset, ParallelSentencesDataset
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/datasets/__init__.py", line 1, in <module>
from .sampler import *
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/datasets/sampler/__init__.py", line 1, in <module>
from .LabelSampler import *
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/datasets/sampler/LabelSampler.py", line 6, in <module>
from ...datasets import SentenceLabelDataset
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/datasets/SentenceLabelDataset.py", line 8, in <module>
from .. import SentenceTransformer
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/SentenceTransformer.py", line 11, in <module>
import transformers
File "/usr/local/lib/python3.6/site-packages/transformers/__init__.py", line 124, in <module>
from .pipelines import (
File "/usr/local/lib/python3.6/site-packages/transformers/pipelines.py", line 47, in <module>
from .modeling_tf_auto import (
File "/usr/local/lib/python3.6/site-packages/transformers/modeling_tf_auto.py", line 45, in <module>
from .modeling_tf_albert import (
File "/usr/local/lib/python3.6/site-packages/transformers/modeling_tf_albert.py", line 43, in <module>
from .modeling_tf_utils import (
File "/usr/local/lib/python3.6/site-packages/transformers/modeling_tf_utils.py", line 943, in <module>
def get_initializer(initializer_range: float = 0.02) -> tf.initializers.TruncatedNormal:
File "/usr/local/lib64/python3.6/site-packages/tensorflow/python/util/module_wrapper.py", line 194, in __getattr__
attr = getattr(self._tfmw_wrapped_module, name)
AttributeError: module 'tensorflow._api.v1.initializers' has no attribute 'TruncatedNormal'
Try:
initializer = tf.keras.initializers.TruncatedNormal()
or
initializer = tf.compat.v1.keras.initializers.TruncatedNormal()
In tensorflow2.3.0,you can't find 'TruncatedNormal' in module 'tensorflow._api.v1.initializers'.
Maybe this version has removed this attribute.

Python3.7 is not compatible with Tensorflow?

I am trying to continue with a Rasa chatbot that I have not used since September and I find a syntax problem with the dependency of Tensorflow. I do not know if this is due to the fact that there are updates to be made with my dependencies or if it due to the fact that I use python3.7 as suggested by people on GitHub, or some other reason.
(moo_env) C:\Users\antoi\Documents\Programming\projects\moodbot>py train_online.py
Traceback (most recent call last):
File "train_online.py", line 37, in <module>
nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/moodnlu')
File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\rasa_core\interpreter.py", line 221, in __init__
self._load_interpreter()
File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\rasa_core\interpreter.py", line 237, in _load_interpreter
self.interpreter = Interpreter.load(self.model_directory)
File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\rasa_nlu\model.py", line 276, in load
skip_validation)
File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\rasa_nlu\model.py", line 298, in create
components.validate_requirements(model_metadata.component_classes)
File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\rasa_nlu\components.py", line 49, in validate_requirements
from rasa_nlu import registry
File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\rasa_nlu\registry.py", line 23, in <module>
from rasa_nlu.classifiers.embedding_intent_classifier import \
File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\rasa_nlu\classifiers\embedding_intent_classifier.py", line 32, in <module>
import tensorflow as tf
File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\tensorflow\__init__.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 114
def TFE_ContextOptionsSetAsync(arg1, async):
SyntaxError: invalid syntax
You can find my code in Github repository
The reason is this line in pywrap_tensorflow_internal.py:
def TFE_ContextOptionsSetAsync(arg1, async):
Since Python 3.5, async (and await) are keywords and can no longer be used as identifiers. I assume you use a very outdated version of tensorflow.

NLTK Not working in MAC OSX

from nltk.tokenize import word_tokenize
k=[]
example=['Mary had a little lamb' , 'Jack went up the hill' , 'Jill followed suit' ,'i woke up suddenly','it was a really bad dream...']
for i in example:
k.append(word_tokenize(i))
I was trying to compile this code but its not compiling and is giving errors which goes as follows :
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/nltk/__init__.py", line 128, in <module>
from nltk.chunk import *
File "/Library/Python/2.7/site-packages/nltk/chunk/__init__.py", line 157, in <module>
from nltk.chunk.api import ChunkParserI
File "/Library/Python/2.7/site-packages/nltk/chunk/api.py", line 13, in <module>
from nltk.parse import ParserI
File "/Library/Python/2.7/site-packages/nltk/parse/__init__.py", line 79, in <module>
from nltk.parse.transitionparser import TransitionParser
File "/Library/Python/2.7/site-packages/nltk/parse/transitionparser.py", line 21, in <module>
from sklearn.datasets import load_svmlight_file
File "/Users/sudhir/Library/Python/2.7/lib/python/site-packages/sklearn/__init__.py", line 57, in <module>
from .base import clone
File "/Users/sudhir/Library/Python/2.7/lib/python/site-packages/sklearn/base.py", line 11, in <module>
from .utils.fixes import signature
File "/Users/sudhir/Library/Python/2.7/lib/python/site-packages/sklearn/utils/__init__.py", line 10, in <module>
from .murmurhash import murmurhash3_32
File "numpy.pxd", line 155, in init sklearn.utils.murmurhash (sklearn/utils/murmurhash.c:5029)
ValueError: numpy.dtype has the wrong size, try recompiling

Sphinx throws an exception on Python 3.4/Windows

I have successfully installed the sphnix on Windows/Python 3.4, then successfully generated a basic structure by calling sphinx-quickstart.
But when calling sphinx-build html or make html, it throws an exception:
D:\my-doc>make html
Traceback (most recent call last):
File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main "__main__", mod_spec)
File "C:\Python34\lib\runpy.py", line 85, in _run_code exec(code, run_globals)
File "C:\Python34\Scripts\sphinx-build.exe\__main__.py", line 9, in <module>
File "C:\Python34\lib\site-packages\sphinx\__init__.py", line 51, in main sys.exit(build_main(argv))
File "C:\Python34\lib\site-packages\sphinx\__init__.py", line 61, in build_main from sphinx import cmdline
File "C:\Python34\lib\site-packages\sphinx\cmdline.py", line 23, in <module> from sphinx.application import Sphinx
File "C:\Python34\lib\site-packages\sphinx\application.py", line 37, in <module> from sphinx.builders import BUILTIN_BUILDERS
File "C:\Python34\lib\site-packages\sphinx\builders\__init__.py", line 23, in <module> from sphinx.util import i18n, path_stabilize
File "C:\Python34\lib\site-packages\sphinx\util\i18n.py", line 15, in <module> from babel.messages.pofile import read_po
File "C:\Python34\lib\site-packages\babel\messages\__init__.py", line 12, in <module> from babel.messages.catalog import *
File "C:\Python34\lib\site-packages\babel\messages\catalog.py", line 23, in <module> from babel.dates import format_datetime
File "C:\Python34\lib\site-packages\babel\dates.py", line 28, in <module> from babel.util import UTC, LOCALTZ
File "C:\Python34\lib\site-packages\babel\util.py", line 278, in <module> from babel import localtime
File "C:\Python34\lib\site-packages\babel\localtime\__init__.py", line 21, in <module> from babel.localtime._win32 import _get_localzone
File "C:\Python34\lib\site-packages\babel\localtime\_win32.py", line 18, in <module> tz_names = get_global('windows_zone_mapping')
File "C:\Python34\lib\site-packages\babel\core.py", line 58, in get_global _global_data = pickle.load(fileobj) TypeError: an integer is required (got type str)
I guess this is about compatibilities, since I have followed the tutorial step by step. Also been googling for this issue for hours and could not find an answer so far. Is it something I'm doing wrong or is it a compatibility issue?
The bug appears to be in babel v2.0. I downgraded to 1.3 (pip install babel==1.3) and the issue went away. Let me know if this works for you.

Resources