-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running Demo (MultiSaver) on Windows #18
Comments
Thanks for your comment! May I ask you a question? I'm wondering if I can use the trained result like YOLO, e.g. import python.darknet as dn dn.set_gpu(0) |
@mj9 Thanks for the hard work and time spent. your solution works like a charm on my windows. |
Hi. I have been trying to run the demo on Windows following your guideline and when I run the program I get this error:
The time increases in the console but I am not getting any results in the output folder, it only creates empty folders. |
I don't think the code in this repository changed much, so I'm guessing my approach still works. Are you sure you implemented it correctly? You could post the code of your |
@mj9 Hi, Can you share your utils.py with us? Send the contents of the document directly to the forum.
|
I don't have access to the code currently, but note how your method t is inside another function. You have to put it directly under MultiSaver |
I spent many hours trying to get this to work under Windows. I managed to get it to work now, so this is probably useful to others.
Setup
The first obstacle is the
readline
Python package, which seems to be default on Unix systems, but not on Windows. For this, simply install thepyreadline
package, which is a Windows port of readline.Understanding the command-line
Example command:
python main.py --save_dir REDS_L1 --demo_input_dir d:/datasets/motion47set/noise_only --demo_output_dir ../results/motion47set
.Explanation: specifying
--demo_input_dir
(or--demo true
) will run an evaluation, using a pretrained model as specified in--save_dir
. Every image of my motion47set will be evaluated. The results will be saved alongside the folderssrc
andexperiments
at the project root, in a folderresults/motion47set
.Note that even getting this far is not very intuitive, as others have already pointed out. Usually there is a separate python script for just evaluation/testing/inference. Next, the term demo is a bit unusual, at first I was expecting some interactive demonstration of some form. The
save_dir
I had at first used as whatdemo_output_dir
does.Another word of caution, if the output path is given without any
.
, it somehow ends up saving the results atd:/results/motion47set
, which again took me a while to figure out, i.e. on the root of the same drive that the project is located at. I suggest printing out the absolute output dir withos.path.abspath
to the user at some point, for clarity.Bug
Running the above command will produce the following output:
Also note that ctrl+c takes a really long time to terminate for me, and even slows down my entire machine for several seconds.
This is difficult to debug, because there is no fatal exception, and everything seems to run normally, ignoring the errors, which might also just be warnings, for all we know. I did not realize for a while that MultiSaver is a file of this project, which is why there is not much help online in regards to this error/warning. Second, the only that that gives a little stronger hint that this is an error, and not a warning, is the
EOFError
, which I still don't know why or where it even happens. A large part of debugging time was me assuming these were just warnings, and trying to fix the command-line arguments instead, since that is easy to get wrong.What is actually happening is that the MultiSaver code runs clean on the main thread, but then each spawned thread/process will fail, without the main thread being aware. As a result, the program runs through, attempts to save the output images, which all do nothing since the threads/processes already died. I'm not sure how to to achieve this, but it would be nice if the program stops running when it is unable to save output images (at least in demo mode, where that's about the only purpose).
The keywords to locate the actual issue here are
pickle
andmultiprocessing
. Going intoutils.py
and looking at the classMultiSaver
shows us a methodbegin_background
, with a method-local variablet
(another method). Defining that method works, however (under Windows) that variable has to be pickled/serialized to hand it over to themp.Process
, which will run it in a different thread/process. This fails because pickle does not support local objects.I tried various ways to change the scope of
t
:global t
before the definition oft
(no change)t
to the outermost scope of the file utils.py, i.e. same level as MutliSaver (can pickle the method, but later fails at a different point)t
on the same scope as MultiSaver, and annotating it with@staticmethod
. The annotation avoids the first method parameter to be used asself
.So my modification looks like this
After this change, everything works as expected. I haven't tested it, but I suspect this will still work under Unix as well.
I'm not sure if this will work if multiple instances of
MultiSaver
are created, and maybe this would give the same result as puttingt
to the outermost scope, i.e. fail again.The text was updated successfully, but these errors were encountered: