I am following this tutorial: https://codelabs.developers.google.com/codelabs/tensorflow-for-poets/?utm_campaign=chrome_series_machinelearning_063016&utm_source=gdev&utm_medium=yt-desc#4
I am running this part of the code:
python retrain.py \
--bottleneck_dir=bottlenecks \
--how_many_training_steps=500 \
--model_dir=inception \
--summaries_dir=training_summaries/basic \
--output_graph=retrained_graph.pb \
--output_labels=retrained_labels.txt \
--image_dir=flower_photos
Here is the error that I get after it finds the images, makes a bunch of bottlenecks and also does steps training.
Traceback (most recent call last):
File "retrain.py", line 1062, in <module>
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
File "C:\Anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "retrain.py", line 905, in main
f.write('\n'.join(image_lists.keys()) + '\n')
File "C:\Anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 101, in write
self._prewrite_check()
File "C:\Anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 87, in _prewrite_check
compat.as_bytes(self.__name), compat.as_bytes(self.__mode), status)
File "C:\Anaconda3\lib\contextlib.py", line 66, in __exit__
next(self.gen)
File "C:\Anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.NotFoundError: Failed to create a NewWriteableFile: /tmp/output_labels.txt : The system cannot find the path specified.
You can find all my code here:
https://github.com/officialgupta/MachineLearningRecipes
Thanks
I have also found some similar errors. And if I understood, that you need to set an absolute paths for --output_graph and --output_labels.
For example:
--output_graph=/home/%your_homhttps://stackoverflow.com/review/late-answers/17020426#e_user_name_folder%/Inception_retrained_graph.pb
--output_labels=/home/%your_home_user_name_folder%/Inception_retrained_labels.txt
I had the same issue. The only thing I had to do is to reduce the length of path.
For example:
C:\Users\test\lib\Workspace\DataScience\Bachelorarbeit\ba_test\src\saved_models\neural20201029-235456-a0.8775
instead of
C:\Users\test\lib\Workspace\DataScience\Bachelorarbeit\ba_test\src\saved_models\neural20201029-234822Arg-e1-b512-l1-n256-oadam-z0.005-r0-d0-a0.8803.
In a similar case,I have met errors, when I tried to execute this command:
writer = tf.python_io.TFRecordWriter(FLAGS.output_path)
then I found that, the output_path is empty. So you need to make sure an absolute paths is available.
I might be late for giving an answer but putting up an answer and hoping that it will be useful for anyone facing similar issue.
Today I came across similar issue while retraining the Inception model on Tensorflow and followed some steps to correct it.
There are two things we need to take care of.
Activate tensorflow before using Tensorflow commands.
source ~/tensorflow/bin/activate
Use full path of the files mentioned in your terminal commands as answered by #Nikita Verbitskiy in the answer below.
try below command in win10 to solve the problem
python -m retrain
--bottleneck_dir=bottlenecks
--how_many_training_steps=500
--model_dir=models
--summaries_dir=tf_files
--output_graph=retrained.pb
--output_labels=retrained_labels.txt
--architecture="mobilenet_0.50_224"
--image_dir=flower_photos
I faced the same problem, and could fix it.
Just to clear some things up, my code is running without ..
setting an absolute path
activating tensorflow
On the first run everything was saved as expected, on the second run I had the same issue as described.
For me it was enough to not set
--save_model_dir
but only setting
--output_labels
--output_graph
Related
When i run setup.py as a script i have no issues reading a parameter file.
When i build with pyinstaller and run the same script as a .exe i receive the below error.
>setup.exe
Traceback (most recent call last):
File "setup.py", line 106, in <module>
param_file_info = paramsfx.extract_param_file_info(param_text)
File "app\paramsfx.py", line 64, in extract_param_file_info
s_n = re.search(rc_n, param_file_text)
File "c:\users\xxxxxx\appdata\local\programs\python\python37-32\lib\re.py", line 183, in search
return _compile(pattern, flags).search(string)
TypeError: cannot use a string pattern on a bytes-like object
[21776] Failed to execute script setup
i have read up on other posts how to resolve this error however before changing the code (that is working fine as a script) i wanted to see if anyone had any thoughts as to why it read the parameter differently as a .exe.
Just from looking at this output and not the code I noticed this:
"TypeError: cannot use a string pattern on a bytes-like object"
If this is true, I would recommend doing some python type conversion. Here is a link to help you out
https://www.w3schools.com/python/trypython.asp?filename=demo_numbers_convert
Because I don't know how your code is structured, choosing which form of conversion you choose may affect your results so please be careful with that.
I hope my explanation could have provided some use to you.
I wrote this code several months ago and wanted to pass through it to clean it up and add some new features. Its a simple tool I used to take a picture of my screen and get write-able words from it. I am on a new computer from the one I originally wrote the code on; however, I went through and installed every module via the pycharm module manager. However, I keep getting this error when I run the code even though I have located the package in my path. Any help would be greatly appreciated.
I've looked up several different variations of my problem but they all seem to have different causes and fixes, of course, none of which work for me.
if c ==2:
img = ImageGrab.grab(bbox=(x1-5, y1-5, x2+5,y2+5)) # bbox specifies region (bbox= x,y,width,height)
img_np = np.array(img)
frame = cv2.cvtColor(img_np, cv2.COLOR_BGR2GRAY)
c = 0
x = 0
string = str(pytesseract.image_to_string(frame)).lower()
print(string)
This is the only section of the code that references pytesseract other than of course "import pytesseract". Hopefully I can get this code up and running again and the pytesseract module in general as it is integral to many of my scripts. Thanks in advance for your help.
File "C:\Users\dante\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 184, in run_tesseract
proc = subprocess.Popen(cmd_args, **subprocess_args())
File "C:\Users\dante\Anaconda3\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:\Users\dante\Anaconda3\lib\subprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/dante/Desktop/DPC/processes/screen_to_text.py", line 29, in <module>
string = str(pytesseract.image_to_string(frame)).lower()
File "C:\Users\dante\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 309, in image_to_string
}[output_type]()
File "C:\Users\dante\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 308, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "C:\Users\dante\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 218, in run_and_get_output
run_tesseract(**kwargs)
File "C:\Users\dante\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 186, in run_tesseract
raise TesseractNotFoundError()
pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path```
The problem was in my lack of understanding of the module. pytesseract is not an OCR, it is simply a translator that allows users to use googles OCR. This means, in order to use this package, a user must have google's OCR installed ( I downloaded mine from here https://sourceforge.net/projects/tesseract-ocr-alt/files/).
This does NOT; however, solve the full problem. The pytesseract package needs to know where the actual OCR program is located. On line 35 of the pytesseract.py script there is a line that tells pytesseract where to find the actual google OCR tesseract program
tesseract_cmd = 'tesseract'
If you are on windows and you haven't manually added tesseract to your path (if you don't know what that means just follow the next steps) then you need to replace that line with the actual location of the google OCR on your computer. Replacing that line with
tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract'
should allow you to run pytesseract assuming you have correctly installed everything. Took me quite a bit longer than i would care to admit to find the blatantly obvious solution to this issue, but hopefully people with this problem in the future resolve it faster than I did! Thanks and have a good day.
I am receiving the following error message when I try to read a Vensim model file (.mdl) using Python's PySD package.
My code is:
import pysd
import os
os.chdir('path/to/model_file')
model = pysd.read_vensim('my_model.mdl')
The Error I receive is:
Traceback (most recent call last):
Python Shell, prompt 13, line 1
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pysd/pysd.py", line 53, in read_vensim
py_model_file = translate_vensim(mdl_file)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pysd/vensim2py.py", line 673, in translate_vensim
entry.update(get_equation_components(entry['eqn']))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pysd/vensim2py.py", line 251, in get_equation_components
tree = parser.parse(equation_str)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/parsimonious/grammar.py", line 123, in parse
return self.default_rule.parse(text, pos=pos)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/parsimonious/expressions.py", line 110, in parse
node = self.match(text, pos=pos)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/parsimonious/expressions.py", line 127, in match
raise error
parsimonious.exceptions.ParseError: Rule 'subscriptlist' didn't match at '' (line 1, column 21).
I have searched for this particular error and I cannot find much information on the failed matching rule for 'subscriptlist'.
I appreciate any insight. Thank you.
Good news is that there is nothing wrong with your code. =) (Although you can also just include the path to the file in the .read_vensim call, if you don't want to make the dir change).
That being the case, there are a few possibilities that would cause this issue. One is if the model file is created with a sufficiently old version of Vensim, the syntax may be different from what the current parser is designed for. One way to get around this is to update Vensim and reload the model file there - Vensim will update to the current syntax.
If you are already using a recent version of Vensim (the parser was developed using syntax of Vensim 6.3E) then the parsing error may be due to a feature that isn't yet included. There are still some outstanding issues with subscripts, which you can read about here and here).
If you aren't using subscripts, you may have found a bug in the parser. If so, best course is to create a report in the github issue tracker for the project. The stack trace you posted says that the error is happening in the first line of the file, and that the error has to do with how the right hand side of the equation is being parsed. You might include the first few lines in your bug report to help me recreate the issue. I'll add a case to our growing test suite and then we can make sure it isn't a problem going forwards.
I've been trying to setup hunpos on my windows system but am experiencing some issues.
The error i get is
File "C:\Users\a\Desktop\x.py", line 25, in <module>
ht = HunposTagger('english.model')
File "C:\Python27-32\lib\site-packages\nltk-2.0.1rc4-py2.7-win32.egg\nltk\tag\hunpos.py", line 84, in __init__
verbose=verbose)
File "C:\Python27-32\lib\site-packages\nltk-2.0.1rc4-py2.7-win32.egg\nltk\internals.py", line 526, in find_binary
url, verbose)
File "C:\Python27-32\lib\site-packages\nltk-2.0.1rc4-py2.7-win32.egg\nltk\internals.py", line 510, in find_file
raise LookupError('\n\n%s\n%s\n%s' % (div, msg, div))
LookupError: ===========================================================================
NLTK was unable to find the hunpos-tag file!
Use software specific configuration paramaters or set the HUNPOS environment variable.
Searched in:
- C:\Users\a\
- .
- /usr/bin
- /usr/local/bin
- /opt/local/bin
- /Applications/bin
- C:\Users\a/bin
- C:\Users\a/Applications/bin
I'm guessing there's a bug in nltk's internals.py but not sure how to fix it. I added os.getcwd() to hunpos_paths in hunpos.py but it doesn't help.
Does anyone know why this is happening?
Thanks
Do you have the file english.model? If you do, set the environment variable HUNPOS to the directory that contains it, and run python again. If you still get an error, check that the directory appears in the list of locations searched.
Did you compile hunpos-tag on your own? If not, and you downloaded the binary from google code or any other place, it cannot be the case that the runnable is actually an exe file (I have no idea whether exe extension is needed by windows for a file to be executable or not), and hunpos.py calls find_binary() to locate hunpos-tag, but not hunpos-tag.exe? I don't know how find_binary() works, but this may be the problem.
from nltk.tag.hunpos import HunposTagger
ht = HunposTagger('english.model', 'hunpos-1.0-win/hunpos-tag.exe')
ht.tag('What is the airspeed of an unladen swallow ?'.split())
ht.close()
You need to set hunpos files paths as arguments.
So I'm trying to use py2app for my project. Now I don't get any errors from py2app. It is writing near the end the following:
/usr/bin/strip: for architecture x86_64 object: /Users/bogdan/Documents/TVB/tvb-root/gemenos/trunk/dist/run.app/Contents/Frameworks/libgfortran.2.dylib malformed object (load command 3 cmdsize not a multiple of 8)
But it build the dist/build folders. But when I try to run my application I get the error:
File "project/core/storage/dao.pyc", line 13, in <module>
File "sqlalchemy/engine/__init__.pyc", line 263, in create_engine
File "sqlalchemy/engine/strategies.pyc", line 50, in create
File "sqlalchemy/engine/url.pyc", line 116, in get_dialect
sqlalchemy.exc.ArgumentError: Could not determine dialect for 'postgresql+psycopg2'.
2011-07-12 15:20:06.680 run[4310:10b] run Error
I tried googling around and the only thing related was:
http://osdir.com/ml/sqlalchemy/2011-05/msg00104.html
but I don't really understand that answer nor do I know if it actually helped at all.
Any suggestion?
Regards,
Bogdan
This may help!! I just struggled through the same problem.
Found this site: (not in english unfortunately, but it worked for me)
http://bancaldo.altervista.org/2011/07/py2exe-errori-post-freeze/
What I did was to add an include to my .py
For MS SQL
from sqlalchemy.dialects.mssql.base import dialect
Or for SQL lite
from sqlalchemy.dialects.sqlite.base import dialect