-
Notifications
You must be signed in to change notification settings - Fork 457
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
[Solution] How to run this project with Python 3.x and TensorFlow 1.x #30
Comments
@hanzhanggit Can you please mention this in readme.md? Thanks! |
After Change I got: How to solve? I use python2.7,how to solve |
@SpadesQ I use Python 3.6 myself so I don't know much about Python 2.7. Maybe You should check if your _traceback file has the same format as mine (by print out its first entry like I did). My traceback file contains 6 items per entry, but for loop only expectd 4 items, so I have to resolve the final items with *. If *_ does not work for you, just use some random variables to fill in the gap like this:
BTW, This TensorFlow versions is a mess, I now use StackGANv2 PyTorch version. |
Hello,why doesn't Prettytensor library include customs_fully_connected/custom_conv2d. |
i am counter the same question @Lotayou , have you solve the question? really thank you |
|
if you use python2.7 , you can do it by change your code curvely: so, you can run ... |
@Lotayou Dear Sir, (base) C:\Users\anwar\Downloads\Programs\Text-to-Image-HighResolution>python run_exp.py --cfg cfg/birds.yml --gpu 0 |
@AnwarUllahKhan I guess there must be a parameter in config file where you can designate the ckpt file to be loaded for subseqeuent training. However if you cannot find one, try convert your tensorflow checkpoint to a pytorch one, and go to the pytorch implementation instead:) |
@Lotayou thank you I solve that. I successfully train this now but how can I run demo which is .sh file and I am on the windows....? |
saved me so much time! thanks! |
@AnwarUllahKhan could you please elaborate on how you fixed it, I am also facing the same problem. And if you have made this project work on windows could you also tell me how you ran the shell script. |
@Lotayou @AnwarUllahKhan @ankit01ojha, I am also facing the same problem with prettytensor for python3.6. Problem:
How did you fix it? |
@akhilvasvani @ankit01ojha you both are using python 3+ so follow the instruction of @Lotayou first message... |
@AnwarUllahKhan, @Lotayou does not mention how to solve the problem. Notice how my error and your error are exactly the same. What did you do to solve your error? |
@akhilvasvani you can try this one too https://www.twblogs.net/a/5c713446bd9eee68dc3f25a0 |
Awesome. Thanks man. Much appreciated |
Ok, so following the link you posted @AnwarUllahKhan, I changed: However, I then hit another error:
Following the solution from the link, get_variable_scope() and get_variable_scope_store() will be called each other continuously and forces the main code to stop running. I didn't know how to add in "current_scope" without messing up the rest of variable_scope.py. So this didn't work. Then I went back to the original problem and changed: However, when I reach the "custom_fully_connected_", I hit the ipdb debugger. Is this a similar path you went down? |
In the ipdb debugger, it finds an error in custom_ops.py with the class custom_fully_connected, specifically with the matrix and and bias variables. I get the error:
This is what is written in the file:
Is there a way around this problem? |
#59 Solved it without using Pretty Tensor |
Oh, I did not train a model for the flower dataset, so you cannot use Han Zhang's pretrained model on my (flower) demo script. Working on training that! |
Could you please tell me where fo find your pre-trained model? |
Unfortunately, I have not posted my pretrained model at the time. At the moment, my focus is training the StackGAN model with skip_thoughts vectors for birds. Once I am done with that, I will get back to training the model for flowers |
Easy Solution to run on windows
|
@akhilvasvani I got error while performing training for updated StackGAN project in your github. https://github.com/akhilvasvani/StackGAN. Can you please help me out |
I am trying to run the sh demo/flowers_demo.sh file and I get an error "Command not found". This is the error upon running the command sh demo/flowers_demo.sh. |
I spent 5 hours getting the program running, which is a great waste of time. I hereby summarize all the necessary changes for this project to run in Python 3.x and TensorFlow r1.x environment.
I assume your working directory is ~/StackGAN/StageI.
1. Python 3.x compatibility issues
In addition to minor changes mentioned in #2, there are still a major issue:
Pickle Issue: The original pickle files are created in Python 2.7, and open it with Python 3 could lead to the following error:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 1: ordinal not in range(128)
The solution can be found here: Unpickle Python 2 object in Python 3
2. TensorFlow r1.x compatibility issues
tf.concat() Issue #11: If you encounter error message like this:
TypeError: Expected int32, got <prettytensor.pretty_tensor_class.Layer object at 0x7f74d41abd90> of type 'Layer' instead.
In TensorFlow r0.12, the function is like
tf.concat(axis, value)
while in TensorFlow r1.x version the argument order has been changed:
tf.concat(value, axis)
PrettyTensor Issue #27: This issue is cause in PrettyTensor module with error message like this:
File ".../site-packages/prettytensor/pretty_tensor_class.py", line 1335, in _strip_unnecessary_contents_from_stack for f, line_no, method, _ in result._traceback: ValueError: too many values to unpack (expected 4)
This issue has nothing to do with PrettyTensor package version, I use the latest 0.7.4 but 0.6.2 should also work.
The main cause of this problem is in _traceback format, in TensorFlow r1.3 the _traceback object is a list with each entry a 6-tuple like this:
('D:\\Anaconda3\\envs\\tensorflow\\lib\\site-packages\\spyder\\utils\\ipython\\start_kernel.py', 241, '<module>', {'__name__': '__main__', '__doc__': '\nFile used to start kernels for the IPython Console\n', '__package__': None, '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x0000021474E75CF8>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, '__file__': 'D:\\Anaconda3\\envs\\tensorflow\\lib\\site-packages\\spyder\\utils\\ipython\\start_kernel.py', '__cached__': None, 'os': <module 'os' from 'D:\\Anaconda3\\envs\\tensorflow\\lib\\os.py'>, 'osp': <module 'ntpath' from 'D:\\Anaconda3\\envs\\tensorflow\\lib\\ntpath.py'>, 'sys': <module 'sys' (built-in)>, 'IS_EXT_INTERPRETER': True, 'sympy_config': <function sympy_config at 0x00000214799891E0>, 'kernel_config': <function kernel_config at 0x0000021479989268>, 'varexp': <function varexp at 0x00000214799892F0>, 'main': <function main at 0x0000021479989378>}, 9, None)
I guess in TensorFlow r0.12 the entry only contains 4 elements. But anyway here's a quick workaround:
Change
for f, line_no, method, _ in result._traceback:
to
for f, line_no, method, *_ in result._traceback:
*_ takes any number of arguments and resolve whatever left in the unpacked tuple.
3. Summary Issue:
TensorFlow r1.3 has a new summary class so many code should be adapted like this:
tf.merge_all_summaries()
->tf.summary.merge_all()
tf.scalar_summary(k,v)
->tf.summary.scalar(k,v)
summary_writer = tf.train.SummaryWriter(self.log_dir, sess.graph)
->summary_writer = tf.summary.FileWriter(self.log_dir, sess.graph)
4. Slicing Index Issue:
The index must be integer, so in
dataset.py
line 80 something should be changed:# cropped_image =\ # images[i][w1: w1 + self._imsize, h1: h1 + self._imsize, :] original_image = images[i] cropped_image = original_image[int(w1): int(w1 + imsize),\ int(h1): int(h1 + imsize), :]
That's all the major compatibility issues that are necessary for training. Enjoy :)
The text was updated successfully, but these errors were encountered: