I'm trying to reproduce results from this repository using docker.
I have completed the pull using
docker pull gasparjan/crnn_ocr:cpu
and run it using
docker run --rm -it -v /home:/data -p 8004:8000 gasparjan/crnn_ocr:cpu
To execute the following command:
python3 predict.py --G 0 --model_path %PATH_TO_MODEL% \
--image_path %PATH_TO_IMAGES% \
--validate --num_instances 512 --max_len 21
I require the PATH_TO_MODEL how do I locate the model.json file that was just pulled?
I've tried using solutions from here but unfortunately I'm unable to locate the pulled directory.
I've also tried downloading the repo from Github and then passing the location of the model.json file and it yields an error
FileNotFoundError: [Errno 2] No such file or directory: '/Users/Luke/Downloads/CRNN-OCR-lite-master/models/OCR_IAM_ver1/model.json'
Please Advise.
I'm using macOS Big Sur.
After running this line:
docker run --rm -it -v /home:/data -p 8004:8000 gasparjan/crnn_ocr:cpu
you will be dropped inside the container's command line. You can look around with ls:
➜ sudo docker run --rm -it -v /home:/data -p 8004:8000 gasparjan/crnn_ocr:cpu
root#0e2914bb1aad:/#
root#0e2914bb1aad:/# ls -la
total 124
drwxr-xr-x 1 root root 4096 Apr 27 13:36 .
drwxr-xr-x 1 root root 4096 Apr 27 13:36 ..
-rwxr-xr-x 1 root root 0 Apr 27 13:36 .dockerenv
drwxr-xr-x 1 root root 4096 May 14 2019 bin
drwxr-xr-x 2 root root 4096 Apr 12 2016 boot
drwxr-xr-x 3 root root 4096 Apr 27 13:35 data
drwxr-xr-x 5 root root 360 Apr 27 13:36 dev
drwxr-xr-x 1 root root 4096 Apr 27 13:36 etc
drwxr-xr-x 2 root root 4096 Apr 12 2016 home
drwxr-xr-x 1 root root 4096 May 14 2019 lib
drwxr-xr-x 1 root root 4096 May 14 2019 lib64
drwxr-xr-x 2 root root 4096 Jan 22 2019 media
drwxr-xr-x 2 root root 4096 Jan 22 2019 mnt
drwxr-xr-x 2 root root 4096 May 14 2019 models
drwxr-xr-x 2 root root 4096 Jan 22 2019 opt
-rw-rw-r-- 1 root root 8034 May 11 2019 predict.py
dr-xr-xr-x 378 root root 0 Apr 27 13:36 proc
drwx------ 1 root root 4096 May 14 2019 root
drwxr-xr-x 1 root root 4096 May 14 2019 run
drwxr-xr-x 1 root root 4096 Jan 22 2019 sbin
drwxr-xr-x 2 root root 4096 Jan 22 2019 srv
dr-xr-xr-x 13 root root 0 Apr 27 13:37 sys
drwxrwxrwt 1 root root 4096 May 14 2019 tmp
-rw-rw-r-- 1 root root 8572 May 10 2019 train.py
drwxr-xr-x 1 root root 4096 Jan 22 2019 usr
-rw-rw-r-- 1 root root 23446 May 10 2019 utils.py
drwxr-xr-x 1 root root 4096 Jan 22 2019 var
root#0e2914bb1aad:/# ls -la /models
total 55892
drwxr-xr-x 2 root root 4096 May 14 2019 .
drwxr-xr-x 1 root root 4096 Apr 27 13:36 ..
-rw-r--r-- 1 root root 490 Jan 24 2019 arguments.txt
-rw-r--r-- 1 root root 11482392 Mar 24 2019 checkpoint_weights.h5
-rw-r--r-- 1 root root 34189880 Jan 24 2019 final_model.h5
-rw-r--r-- 1 root root 11482392 Jan 24 2019 final_weights.h5
-rw-r--r-- 1 root root 136 Jan 24 2019 loss_history.pickle.dat
-rw-r--r-- 1 root root 31729 Jan 24 2019 model.json
-rw-r--r-- 1 root root 15524 Jan 24 2019 model_summary.txt
So the file is at /models/model.json inside the container!
As for the images, I couldn't find any images inside the container. I think you are meant to supply your own. In that case, look at the command (/home:/data). This is a bind mount which means that /home on your PC and /data inside the container are the same folder now.
So I would try adding some images to your PC's /home folder and then, inside the container, running:
python3 predict.py --G 0 --model_path /models/model.json \
--image_path /data \
--validate --num_instances 512 --max_len 21
I am a newbie at this. But I think I have a solution.
I pulled the docker image and it seems like if you replace %PATH_TO_MODEL% with models in your python3 command - it works!
Here is what the final command looks like:
python3 predict.py --G 0 --model_path models \
--image_path %PATH_TO_IMAGES% \
--validate --num_instances 512 --max_len 21
If you do ls once you are inside the docker container, you will be able to see all the directories.
__pycache__ boot dev home lib64 mnt opt proc run srv tmp usr var
bin data etc lib media models predict.py root sbin sys train.py utils.py
I am not sure if this helps, but let me know.
Related
I'm on windows wsl2, and I have 3 pythons. Which one do I keep or should I no touch them? I was reading an article on how to fix import errors and it might be because I have more than 1 python version(more than one pip). When I type python --version and python3 --version, I get 3.9.12 on both
These are usually symbolic links. It helps resolving the main python interpreter without having to specify the full target version.
Try running ls -l. It should gives you something similar to this (in my case I ran ls -l /bin/python*):
lrwxrwxrwx 1 root root 7 Apr 15 2020 /bin/python -> python2
lrwxrwxrwx 1 root root 9 Mar 13 2020 /bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3.6M Mar 8 2021 /bin/python2.7
lrwxrwxrwx 1 root root 9 Feb 25 2022 /bin/python3 -> python3.8
-rwxr-xr-x 1 root root 5.3M Mar 15 2022 /bin/python3.8
lrwxrwxrwx 1 root root 33 Mar 15 2022 /bin/python3.8-config -> x86_64-linux-gnu-python3.8-config
lrwxrwxrwx 1 root root 16 Mar 13 2020 /bin/python3-config -> python3.8-config
-rwxr-xr-x 1 root root 5.8K Jan 13 2020 /bin/python3-wsdump
I am using this command:
./configure --enable-2d-adaptivity
in order to create an executable for an open source code I would like to install in a folder outside the container.
But I get this error when it stops:
checking for Fortran 77 name-mangling scheme... lower case, underscore, no extra underscore
configure: Checking for Python automagic.
configure: No Python automagic.
checking for python... no
configure: error: Cannot find python in your system path`
This code require Python 2.7 and it is installed in /usr/bin.
When I use ls -l :
Singularity> ls -l /usr/bin/python*
-rwxr-xr-x 1 root root 3628976 Sep 30 09:38 /usr/bin/python2.7
lrwxrwxrwx 1 root root 33 Sep 30 09:38 /usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root 9 Oct 25 2018 /usr/bin/python3 -> python3.6
lrwxrwxrwx 1 root root 16 Oct 25 2018 /usr/bin/python3-config -> python3.6-config
-rwxr-xr-x 1 root root 384 Apr 11 2018 /usr/bin/python3-futurize
-rwxr-xr-x 1 root root 388 Apr 11 2018 /usr/bin/python3-pasteurize
-rwxr-xr-x 1 root root 364 Aug 22 2016 /usr/bin/python3-qr
-rwxr-xr-x 2 root root 4526456 Oct 8 08:12 /usr/bin/python3.6
lrwxrwxrwx 1 root root 33 Oct 8 08:12 /usr/bin/python3.6-config -> x86_64-linux-gnu-python3.6-config
-rwxr-xr-x 2 root root 4526456 Oct 8 08:12 /usr/bin/python3.6m
lrwxrwxrwx 1 root root 34 Oct 8 08:12 /usr/bin/python3.6m-config -> x86_64-linux-gnu-python3.6m-config
lrwxrwxrwx 1 root root 10 Oct 25 2018 /usr/bin/python3m -> python3.6m
lrwxrwxrwx 1 root root 17 Oct 25 2018 /usr/bin/python3m-config -> python3.6m-config
So probably a solution could be to set python to point at Python 2.7?
I tried many commands but they didn't worked.
In addition when I run which python it is empty.
How can I fix it?
Should the folder be in the container instead of my home directory?
The folder in which I run the command ./configure --enable-2d-adaptivity is located in the home directory of my account on a super computer. I can see it from the container.
Thank you!
so I suspect I have a Python installation problem. I was doing some coding in python. Everything was running just fine then it just stopped loading scapy for no particular reason at all. Unable to import Scapy. I tried lots of things and in the end gave up on it as it was taking too long to figure out and wasn't really that important anyway.
So now I am doing something else that has a Python dependency. I am using Maltego with some custom transforms that I have downloaded. They are Python dependent and getting these transforms working will save me a ton of time.
The error in Maltego when it runs is:
Traceback (most recent call last):
File "/opt/maltego-nmap/units/nmap_xml_parser.py", line 4, in <module>
from lxml import etree
ImportError: No module named lxml
The python root path in maltego is shown as /usr/bin/python
So I checked my python path:
KALI606:/usr/bin# type -a python
python is /usr/bin/python
python is /bin/python
KALI606:/usr/bin# cd bin/python
bash: cd: bin/python: No such file or directory
KALI606:/usr/bin# cd usr/bin/python
bash: cd: usr/bin/python: No such file or directory
KALI606:/usr/bin# ls -l python*
lrwxrwxrwx 1 root root 7 Nov 18 06:36 python -> python2
lrwxrwxrwx 1 root root 9 Nov 18 06:36 python2 -> python2.7
-rwxr-xr-x 1 root root 3647800 Jan 19 19:54 python2.7
lrwxrwxrwx 1 root root 33 Jan 19 19:54 python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root 16 Nov 18 06:36 python2-config -> python2.7-config
-rwxr-xr-x 1 root root 385 Feb 2 03:10 python2-futurize
-rwxr-xr-x 1 root root 389 Feb 2 03:10 python2-pasteurize
lrwxrwxrwx 1 root root 9 Nov 14 14:13 python3 -> python3.7
-rwxr-xr-x 2 root root 5114928 Mar 10 13:18 python3.7
lrwxrwxrwx 1 root root 33 Mar 10 13:18 python3.7-config -> x86_64-linux-gnu-python3.7-config
-rwxr-xr-x 2 root root 5114928 Mar 10 13:18 python3.7m
lrwxrwxrwx 1 root root 34 Mar 10 13:18 python3.7m-config -> x86_64-linux-gnu-python3.7m-config
-rwxr-xr-x 1 root root 5453504 Feb 25 13:04 python3.8
lrwxrwxrwx 1 root root 16 Nov 14 14:13 python3-config -> python3.7-config
-rwxr-xr-x 1 root root 384 Feb 2 03:10 python3-futurize
-rwxr-xr-x 1 root root 398 Sep 7 2018 python3-jsonschema
lrwxrwxrwx 1 root root 10 Nov 14 14:13 python3m -> python3.7m
lrwxrwxrwx 1 root root 17 Nov 14 14:13 python3m-config -> python3.7m-config
-rwxr-xr-x 1 root root 388 Feb 2 03:10 python3-pasteurize
-rwxr-xr-x 1 root root 364 Dec 15 18:09 python3-qr
-rwxr-xr-x 1 root root 196 Oct 6 2019 python3-tor-prompt
-rwxr-xr-x 1 root root 5902 Oct 1 2018 python3-wsdump
lrwxrwxrwx 1 root root 14 Nov 18 06:36 python-config -> python2-config
lrwxrwxrwx 1 root root 7 Feb 4 14:30 python-faraday -> faraday
This is a mess right?
Any suggestions on how I can sort out Python pls? I feel like I want to just remove all python references and start clean but I have limited knowledge on this. The Maltego error is very similar to the scapy error I had.
I am running the latest version of Kali.
Try to install python2-lxml with something like
sudo apt-get install python2-lxml
When I deployment don't get any problem to run, but when I trying run with apache wsgi got this error: DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory"
Tried to use ldconfig and setup on environment LD_LIBRARY_PATH but didn't worked. The server is a linux x64 with cx_oracle 7.2.0 and django 1.11.22 with python 2.7.15+ and installing libaio.
root#webservice:/opt/instantclient_11_2# ls -la
lrwxrwxrwx 1 root root 17 Jul 10 15:41 libclntsh.so -> libclntsh.so.11.1
-rwxrwxr-x 1 root root 53865194 Aug 24 2013 libclntsh.so.11.1
-r-xr-xr-x 1 root root 7996693 Aug 24 2013 libnnz11.so
lrwxrwxrwx 1 root root 15 Jul 10 15:41 libocci.so -> libocci.so.11.1
-rwxrwxr-x 1 root root 1973074 Aug 24 2013 libocci.so.11.1
-rwxrwxr-x 1 root root 118738042 Aug 24 2013 libociei.so
-r-xr-xr-x 1 root root 164942 Aug 24 2013 libocijdbc11.so
-r--r--r-- 1 root root 2091135 Aug 24 2013 ojdbc5.jar
-r--r--r-- 1 root root 2739616 Aug 24 2013 ojdbc6.jar
-rwxrwxr-x 1 root root 192365 Aug 24 2013 uidrvci
-rw-rw-r-- 1 root root 66779 Aug 24 2013 xstreams.jarre
root#webservice:/opt/instantclient_11_2# cat /etc/ld.so.conf.d/oracle-instantclient.conf
/opt/instantclient_11_2
export LD_RUN_PATH:
export LD_RUN_PATH=$LD_LIBRARY_PATH
On a small embedded Linux device with limited space, I am trying to place the large [10 Mb] Amazon (AWS) BotoCore library (https://github.com/boto/botocore) in a zip file to compress it and then import it in my Python Scripts using zipimport as described in PEP273 (https://www.python.org/dev/peps/pep-0273/).
I modified my script to have the following lines at the beginning:
## Use zip imports
import sys
sys.path.insert(0, '/usr/lib/python2.7/site-packages/site-packages.zip')
The site-packages zip file only has botocore in it and site-packages directory itself has the other modules I use, but excluding botocore, in it.
Here is a listing of that directory:
/usr/lib/python2.7/site-packages >> ls -rlt
total 1940
-rw-rw-r-- 1 root root 32984 Jun 8 12:22 six.pyc
-rw-r--r-- 1 root root 119 Jun 11 07:43 README
drwxrwxr-x 2 root root 4096 Jun 11 07:43 requests-2.4.3-py2.7.egg-info
drwxrwxr-x 2 root root 4096 Jun 11 07:43 six-1.9.0-py2.7.egg-info
drwxrwxr-x 2 root root 4096 Jun 11 07:43 python_dateutil-2.4.2-py2.7.egg-info
drwxrwxr-x 2 root root 4096 Jun 11 07:43 jmespath-0.7.0-py2.7.egg-info
-rw-rw-r-- 1 root root 2051 Jun 11 07:44 pygtk.pyc
-rw-rw-r-- 1 root root 1755 Jun 11 07:44 pygtk.pyo
-rw-rw-r-- 1 root root 8 Jun 11 07:44 pygtk.pth
drwxrwxr-x 2 root root 4096 Jun 11 07:44 futures-2.2.0-py2.7.egg-info
drwxrwxr-x 3 root root 4096 Jun 11 07:44 gtk-2.0
drwxrwxr-x 3 root root 4096 Jun 11 07:44 requests
drwxrwxr-x 3 root root 4096 Jun 11 07:44 dbus
drwxrwxr-x 3 root root 4096 Jun 11 07:44 dateutil
drwxrwxr-x 2 root root 4096 Jun 11 07:44 jmespath
drwxrwxr-x 3 root root 4096 Jun 11 07:44 concurrent
drwxrwxr-x 2 root root 4096 Jun 11 07:44 futures
drwxrwxr-x 2 root root 4096 Jun 12 10:42 gobject
drwxrwxr-x 2 root root 4096 Jun 12 10:42 glib
-rwxr-xr-x 1 root root 5800 Jun 12 10:42 _dbus_glib_bindings.so
-rwxr-xr-x 1 root root 77680 Jun 12 10:42 _dbus_bindings.so
-rwxr-xr-x 1 root root 1788623 Jun 12 11:39 site-packages.zip
And here are the contents of that zipfile:
My problem is that I can import boto3 and import botocore just find, but when I try to use some API methods contained therein, I get exceptions like this:
>> Unknown component: enpoint_resolver
or
>> Unable to load data for: aws/_endpoints!
If I remove the zip file after uncompressing it in the site-packages directory and reboot - my script works fine.
How can I leverage zipfile imports to compress this huge library? Thanks!
Unfortunately, this just isn't going to work.
PEP 273 requires library authors to follow certain rules, which this package does not. In particular, it makes use of __file__ rather than pkgutil.get_data() or an equivalent API. As a result, the files must actually exist in the filesystem.
You might try using FUSE to mount the .zip file in the filesystem, so it appears to Python as if it's uncompressed, without actually taking up all that disk space. Just looking through Google, I came up with fuse-zip, which looks like it could be suitable. You'll want to run some benchmarks to ensure it performs well on your system.