CycleGAN-TensorFlow
CycleGAN-TensorFlow copied to clipboard
Batch inference?
For example, I have a lot of unpaired images from two domain, A and B. After training, what should I do to transfer A to B with the model?
AND! When will the model stop? What is the meaning of "coord.should_stop"? Are there any parts we can use to test? Hoping for your reply, thanks!
@irfanICMLL after training, you can export model from checkpoint using export_graph.py
script as described in https://github.com/vanhuyz/CycleGAN-TensorFlow/blob/master/README.md#export-model.
After that, you can use the model to transfer images as https://github.com/vanhuyz/CycleGAN-TensorFlow/blob/master/README.md#inference.
You can stop the training anytime you want by Ctrl+C. You can use TensorBoard to see the training process with generated images on the Image tab.
Please let me know if you have any trouble :)
Thanks a lot~ But it will be helpful if we have a test part~
Sure! What kind of test do you want?
The datasets are divided into train set and test set. Do you use the test set? I guess the test set is design to test the effects of the model. For example, after the training, if we ues a test part. We can see a genA represents the generated results from testB and a genB represents the generated results from testA. Then we can make collateral experiments and get the results easily instead of watching at the Tensorboard.
Yes, I used the test set for that purpose too. The inference.py
script can be used to generate an image from testA. To convert a whole directory, we need to modify that script a bit. Is that what you mean?
Yes, I think an automatic script may be more effective to show the results.
在 2017-05-16 16:50:22,"Van Huy" [email protected] 写道:
Yes, I used the test set for that purpose too. The inference.py script can be used to generate an image from testA. To convert the whole directory, we need to modify that script a bit. Is that what you mean?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
I have an inference.py that can do batches. I'm new to using tensorflow (and python) so I'm not sure if it's the most optimal. When it runs, there's a message saying "Creating Tensorflow Device" for each batch. It's at https://github.com/rosswendt/CycleGAN-TensorFlow/blob/batched_inference/inference.py. Let me know what you think.
Hi Ross, I've checked your code. It looks like you try to create many different graphs in the loop, and each graph only does inference for 1 image. https://github.com/rosswendt/CycleGAN-TensorFlow/blob/batched_inference/inference.py#L46
I think there is a more efficient way to do batch inference by using only 1 graph.
But we have to modify export_graph.py
a bit. At the moment, the exported graph only accepts 1 image as input. But we can make it accept multiple images as input by:
# https://github.com/vanhuyz/CycleGAN-TensorFlow/blob/master/export_graph.py#L33
- input_image = tf.placeholder(tf.float32, shape=[FLAGS.image_size, FLAGS.image_size, 3], name='input_image')
+ input_images = tf.placeholder(tf.float32, shape=[None, FLAGS.image_size, FLAGS.image_size, 3], name='input_images')
...
- output_image = cycle_gan.G.sample(tf.expand_dims(input_image, 0))
+ output_images = cycle_gan.G.sample(input_images)
# (we may have to modify sample method in generator.py too)
Sorry that I can't check whether it works right now, but what do you think?
Hi Van!
Thanks so much for checking the code out. And thanks for the work you've done and continue to do on this project. It's very cool to have a tensorflow implementation of CycleGAN.
I'm working through some of the tensorflow tutorials so I can better make modifications to the script. I'm trying to learn some python best practices as well, since I'm a bit new to it too.
I'll try out your tweaks this coming week, in addition to learning a bit more tensorflow and python stuff. Hopefully I will be able to write things cleaner and better performing as I learn more.
Thanks again for taking a look at my script with all the work you've done on this tensorflow CycleGAN implementation.
I write a batch test function. batch_test
You may refer to the this gist, which can infer a batch of images in the same directory.