unable to from Convert Pascal VOC to tfrecords for tensor flow object detection API - computer-vision

unable to from Convert Pascal VOC to tfrecords for tensor flow object detection API , reference : https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html#create-tensorflow-records
!python /workspace/scripts/generate_tfrecord1.py -x /workspace/kitti_dataset/training -l /workspace/annotations/label_map.pbtxt -o /workspace/annotations/train.record
!python /workspace/scripts/generate_tfrecord1.py -x /workspace/kitti_dataset/validation -l /workspace/annotations/label_map.pbtxt -o /workspace/annotations/train.record
error that I am getting :
/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/__init__.py:98: UserWarning: unable to load libtensorflow_io_plugins.so: unable to open file: libtensorflow_io_plugins.so, from paths: ['/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/libtensorflow_io_plugins.so']
caused by: ['/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/libtensorflow_io_plugins.so: undefined symbol: _ZN3tsl5mutexC1Ev']
warnings.warn(f"unable to load libtensorflow_io_plugins.so: {e}")
/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/__init__.py:104: UserWarning: file system plugins are not loaded: unable to open file: libtensorflow_io.so, from paths: ['/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/libtensorflow_io.so']
caused by: ['/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/libtensorflow_io.so: undefined symbol: _ZNK10tensorflow4data11DatasetBase8FinalizeEPNS_15OpKernelContextESt8functionIFN3tsl8StatusOrISt10unique_ptrIS1_NS5_4core15RefCountDeleterEEEEvEE']
warnings.warn(f"file system plugins are not loaded: {e}")
Traceback (most recent call last):
File "/workspace/scripts/generate_tfrecord1.py", line 172, in <module>
tf.app.run()
File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/platform/app.py", line 36, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/usr/local/lib/python3.8/dist-packages/absl/app.py", line 312, in run
_run_main(main, args)
File "/usr/local/lib/python3.8/dist-packages/absl/app.py", line 258, in _run_main
sys.exit(main(argv))
File "/workspace/scripts/generate_tfrecord1.py", line 159, in main
examples = xml_to_csv(args.xml_dir)
File "/workspace/scripts/generate_tfrecord1.py", line 92, in xml_to_csv
int(bndbox.find('xmin').text),
ValueError: invalid literal for int() with base 10: '\n 692.09\n '
/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/__init__.py:98: UserWarning: unable to load libtensorflow_io_plugins.so: unable to open file: libtensorflow_io_plugins.so, from paths: ['/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/libtensorflow_io_plugins.so']
caused by: ['/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/libtensorflow_io_plugins.so: undefined symbol: _ZN3tsl5mutexC1Ev']
warnings.warn(f"unable to load libtensorflow_io_plugins.so: {e}")
/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/__init__.py:104: UserWarning: file system plugins are not loaded: unable to open file: libtensorflow_io.so, from paths: ['/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/libtensorflow_io.so']
caused by: ['/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/libtensorflow_io.so: undefined symbol: _ZNK10tensorflow4data11DatasetBase8FinalizeEPNS_15OpKernelContextESt8functionIFN3tsl8StatusOrISt10unique_ptrIS1_NS5_4core15RefCountDeleterEEEEvEE']
warnings.warn(f"file system plugins are not loaded: {e}")
Traceback (most recent call last):
File "/workspace/scripts/generate_tfrecord1.py", line 172, in <module>
tf.app.run()
File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/platform/app.py", line 36, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/usr/local/lib/python3.8/dist-packages/absl/app.py", line 312, in run
_run_main(main, args)
File "/usr/local/lib/python3.8/dist-packages/absl/app.py", line 258, in _run_main
sys.exit(main(argv))
File "/workspace/scripts/generate_tfrecord1.py", line 159, in main
examples = xml_to_csv(args.xml_dir)
File "/workspace/scripts/generate_tfrecord1.py", line 92, in xml_to_csv
int(bndbox.find('xmin').text),
ValueError: invalid literal for int() with base 10: '583.43'
unable to from Convert Pascal VOC to tfrecords for tensor flow object detection API training

The cause is that you have renamed the image after labeling, causing the image name (.jpg) and label file name (.XML) to not match, resulting in the name in the image and CSV file not matching.
The solution is to create the script to rename the XML file.
and then exported to CSV again

Related

Can't install django-mailgun

I want to install django-mailgun library. Followed this tutorial https://learnbatta.com/blog/django-send-email-using-mailgun-api-94/
I tried
pip install django-mailgun --verbose
Log of command:
Using pip 21.0.1 from /home/alex/.local/lib/python3.6/site-packages/pip (python 3.6)
Defaulting to user installation because normal site-packages is not writeable
Created temporary directory: /tmp/pip-ephem-wheel-cache-r4kdc56j
Created temporary directory: /tmp/pip-req-tracker-s1r35ye8
Initialized build tracking at /tmp/pip-req-tracker-s1r35ye8
Created build tracker: /tmp/pip-req-tracker-s1r35ye8
Entered build tracker: /tmp/pip-req-tracker-s1r35ye8
Created temporary directory: /tmp/pip-install-14dd83we
1 location(s) to search for versions of django-mailgun:
* https://pypi.org/simple/django-mailgun/
Fetching project page and analyzing links: https://pypi.org/simple/django-mailgun/
Getting page https://pypi.org/simple/django-mailgun/
Found index url https://pypi.org/simple
Looking up "https://pypi.org/simple/django-mailgun/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): pypi.org:443
https://pypi.org:443 "GET /simple/django-mailgun/ HTTP/1.1" 404 13
Status code 404 not in (200, 203, 300, 301)
Could not fetch URL https://pypi.org/simple/django-mailgun/: 404 Client Error: Not Found for url: https://pypi.org/simple/django-mailgun/ - skipping
Given no hashes to check 0 links for project 'django-mailgun': discarding no candidates
ERROR: Could not find a version that satisfies the requirement django-mailgun
ERROR: No matching distribution found for django-mailgun
Exception information:
Traceback (most recent call last):
File "/home/alex/.local/lib/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.py", line 171, in _merge_into_criterion
crit = self.state.criteria[name]
KeyError: 'django-mailgun'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/alex/.local/lib/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.py", line 318, in resolve
name, crit = self._merge_into_criterion(r, parent=None)
File "/home/alex/.local/lib/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.py", line 173, in _merge_into_criterion
crit = Criterion.from_requirement(self._p, requirement, parent)
File "/home/alex/.local/lib/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.py", line 83, in from_requirement
raise RequirementsConflicted(criterion)
pip._vendor.resolvelib.resolvers.RequirementsConflicted: Requirements conflict: SpecifierRequirement('django-mailgun')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/alex/.local/lib/python3.6/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 122, in resolve
requirements, max_rounds=try_to_avoid_resolution_too_deep,
File "/home/alex/.local/lib/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.py", line 453, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File "/home/alex/.local/lib/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.py", line 320, in resolve
raise ResolutionImpossible(e.criterion.information)
pip._vendor.resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=SpecifierRequirement('django-mailgun'), parent=None)]
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/alex/.local/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 189, in _main
status = self.run(options, args)
File "/home/alex/.local/lib/python3.6/site-packages/pip/_internal/cli/req_command.py", line 178, in wrapper
return func(self, options, args)
File "/home/alex/.local/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 317, in run
reqs, check_supported_wheels=not options.target_dir
File "/home/alex/.local/lib/python3.6/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 127, in resolve
six.raise_from(error, e)
File "<string>", line 3, in raise_from
pip._internal.exceptions.DistributionNotFound: No matching distribution found for django-mailgun
Removed build tracker: '/tmp/pip-req-tracker-wgh79mc3'
OS -- Ubuntu 16.04 LTS
That command is wrong, you need to follow the official command: pip install django-mailgun-mime

Error converting Tensorflow Object Detection Api model to TFLite

I trained a SSDLite-MobilenetV2 model with Tensorflow using the provided documentation in the Object Detection Api. Then I exported the model by running the export_tflite_ssd_graph script. A pb and a pbtxt file were generated. Finally, I tried to convert the model to tflite format using the tflite_convert command. However, I got the following error:
Traceback (most recent call last):
File "/usr/local/bin/tflite_convert", line 11, in
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 412, in main
app.run(main=run_main, argv=sys.argv[:1])
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 408, in run_main
_convert_model(tflite_flags)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 100, in _convert_model
converter = _get_toco_converter(flags)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 87, in _get_toco_converter
return converter_fn(**converter_kwargs)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/lite/python/lite.py", line 340, in from_saved_model
output_arrays, tag_set, signature_key)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/lite/python/convert_saved_model.py", line 239, in freeze_saved_model
meta_graph = get_meta_graph_def(saved_model_dir, tag_set)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/lite/python/convert_saved_model.py", line 61, in get_meta_graph_def
return loader.load(sess, tag_set, saved_model_dir)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/saved_model/loader_impl.py", line 197, in load
return loader.load(sess, tags, import_scope, **saver_kwargs)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/saved_model/loader_impl.py", line 350, in load
** saver_kwargs)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/saved_model/loader_impl.py", line 275, in load_graph
meta_graph_def = self.get_meta_graph_def_from_tags(tags)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/saved_model/loader_impl.py", line 251, in get_meta_graph_def_from_tags
" could not be found in SavedModel. To inspect available tag-sets in"
RuntimeError: MetaGraphDef associated with tags set(['serve']) could not be found in SavedModel. To inspect available tag-sets in the SavedModel, please use the SavedModel CLI: saved_model_cli
It seems that the conversion script did not include the SERVING tag constant. How can I fix this?
I am using tensorflow-gpu 1.12.0

ERAlchemy cannot connect to database

I don't understand the syntax to call the render feature of ERAlchemy (https://pypi.org/project/ERAlchemy see "Usage for Python"). I am using Python 2.7, sqlite3, and PyCharm. I have ERAlchemy, GraphViz, and PyGraphViz installed.
I am trying the following, but it cannot connect to the database:
from eralchemy import render_er
render_er("sqlite:///C:\\Users\\myname\\Documents\\Work\\pythonsqlite.db", 'erd_from_sqlite.png')
And this is the error:
Traceback (most recent call last):
File "C:/Users/myname/Documents/Work/_sql_functions_rev0.py", line 81, in <module>
render_er("sqlite:///C:\\Users\\myname\\Documents\\Work\\pythonsqlite.db", 'erd_from_sqlite.png')
File "C:\Python27\ArcGISx6410.6\lib\site-packages\eralchemy\main.py", line 236, in render_er
intermediary_to_output(tables, relationships, output)
File "C:\Python27\ArcGISx6410.6\lib\site-packages\eralchemy\main.py", line 75, in intermediary_to_schema
graph.draw(path=output, prog='dot', format=extension)
File "C:\Python27\ArcGISx6410.6\lib\site-packages\pygraphviz\agraph.py", line 1474, in draw
data = self._run_prog(prog, args)
File "C:\Python27\ArcGISx6410.6\lib\site-packages\pygraphviz\agraph.py", line 1308, in _run_prog
runprog = r'"%s"' % self._get_prog(prog)
File "C:\Python27\ArcGISx6410.6\lib\site-packages\pygraphviz\agraph.py", line 1295, in _get_prog
raise ValueError("Program %s not found in path." % prog)
ValueError: Program dot not found in path.
Ah! Found the answer here
had to find the folder with "dot.exe" and add it to the environment variables -> system variables -> path

OSError: libmediainfo.so.0: cannot open shared object file: No such file or directory from aws lambda

I am using pymediainfo in lambda function , and I have followed the answer from this so question .
The function has the below code
from pymediainfo import MediaInfo
s3_bucket_file_key = 'https://s3-region.amazonaws.com/sample-bucket/sample_video.mov'
media_info = MediaInfo.parse(s3_bucket_file_key)
media_info_json = media_info.to_json()
Can someone please help me , the sample bucket is public , and I can run this code on my system . but getting the below error from Cloudwatch in aws-lambda.
It seems like libmediainfo is a os related package, I am not sure how to export it to the python deployment package.
anupam:Videos$ apt-cache search libmediainfo
libmediainfo-dev - library reading metadata from media files -- headers
libmediainfo-doc - library for reading metadata from media files -- documentation
libmediainfo0v5 - library for reading metadata from media files -- shared library
error
libmediainfo.so.0: cannot open shared object file: No such file or directory: OSError
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 166, in lambda_handler
media_info = MediaInfo.parse(key)
File "/var/task/pymediainfo/__init__.py", line 183, in parse
lib = cls._get_library(library_file)
File "/var/task/pymediainfo/__init__.py", line 155, in _get_library
return CDLL("libmediainfo.so.0")
File "/usr/lib64/python2.7/ctypes/__init__.py", line 357, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libmediainfo.so.0: cannot open shared object file: No such file or directory
When I added libmediainfo.so.0 manually to the command
media_info = MediaInfo(video_file, library_file='path/to/libmediainfo')
I am getting the below error now for libzen.so.0
libzen.so.0: cannot open shared object file: No such file or directory: OSError
Traceback (most recent call last):
File "/var/task/erlabs.py", line 166, in lambda_handler
media_info = MediaInfo.parse(key,library_file='libmediainfo.so.0')
File "/var/task/pymediainfo/__init__.py", line 183, in parse
lib = cls._get_library(library_file)
File "/var/task/pymediainfo/__init__.py", line 146, in _get_library
return CDLL(library_file)
File "/usr/lib64/python2.7/ctypes/__init__.py", line 357, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libzen.so.0: cannot open shared object file: No such file or directory

how to use envoy package in python?

I have installed package envoy. I ran the script but a windows error occured .I commented envoy.run then the full script runs but when I remove the comment, error occurs.
import envoy
# This data is checked-in to the repository and is a compressed
# version of the output from Example 3
F = 'resources/ch06-mailboxes/data/enron.mbox.json.bz2'
r = envoy.run("bunzip2 %s" % (F,))
print r.std_out
print r.std_err
traceback of script:
Exception in thread Thread-9:
Traceback (most recent call last):
File "C:\Users\sachin\Anaconda\lib\threading.py", line 810, in __bootstrap_inner
self.run()
File "C:\Users\sachin\Anaconda\lib\threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "C:\Users\sachin\Anaconda\lib\site-packages\envoy\core.py", line 40, in target
bufsize=0,
File "C:\Users\sachin\Anaconda\lib\subprocess.py", line 709, in __init__
errread, errwrite)
File "C:\Users\sachin\Anaconda\lib\subprocess.py", line 957, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Please try this:
F = os.path.join(os.getcwd(), 'resources/ch06-mailboxes/data/enron.mbox.json.bz2')