Permalink
Browse files

update

  • Loading branch information...
Ireneruru committed Mar 8, 2017
1 parent c5c123b commit f519ef5014d9efe616272bb4bc83e6e54e74e79f
Showing with 344 additions and 29 deletions.
  1. BIN .DS_Store
  2. +11 −0 .idea/GalaxyGAN_python.iml
  3. +4 −0 .idea/misc.xml
  4. +8 −0 .idea/modules.xml
  5. +6 −0 .idea/vcs.xml
  6. +293 −0 .idea/workspace.xml
  7. +3 −3 config.py
  8. +3 −10 data.py
  9. +0 −2 model.py
  10. +3 −5 test.py
  11. +13 −9 train.py
View
BIN +6 KB .DS_Store
Binary file not shown.
View
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>
View
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 2.7.13 (/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/bin/python2.7)" project-jdk-type="Python SDK" />
</project>
View
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/GalaxyGAN_python.iml" filepath="$PROJECT_DIR$/.idea/GalaxyGAN_python.iml" />
</modules>
</component>
</project>
View
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,7 +1,7 @@
class Config:
data_path = "./figures"
data_path = "/Users/ruru/Desktop/10_jpg"
model_path = "" #"./datasets/facades/checkpoint/model_100.ckpt"
output_path = "./results"
output_path = "/Users/ruru/Desktop/10_jpg"
img_size = 424
adjust_size = 500
@@ -13,4 +13,4 @@ class Config:
beta1 = 0.5
max_epoch = 200
L1_lambda = 100
save_per_epoch=5
save_per_epoch=1
View
13 data.py
@@ -3,20 +3,13 @@
import os
def load(path):
imgs = []
for i in os.listdir(path):
all = imread(path + "/" + i)
img, cond = all[:,:conf.img_size], all[:,conf.img_size:]
imgs.append((img, cond))
return imgs
yield (img, cond, i)
def load_data():
data = dict()
data["train"] = load(conf.data_path + "/train")
# data["val"] = load(conf.data_path + "/val")
data["test"] = load(conf.data_path + "/test")
data["train"] = lambda: load(conf.data_path + "/train")
data["test"] = lambda: load(conf.data_path + "/test")
return data
View
@@ -1,8 +1,6 @@
import math
from config import Config as conf
from utils import conv2d, deconv2d, linear, batch_norm, lrelu
import tensorflow as tf
from IPython import embed
class CGAN(object):
View
@@ -35,16 +35,14 @@ def test():
with tf.Session() as sess:
saver.restore(sess, conf.model_path)
test_data = data["train"]
test_count = 0
for img, cond in test_data:
test_count += 1
test_data = data["train"]()
for img, cond, name in test_data:
pimg, pcond = prepocess_test(img, cond)
gen_img = sess.run(model.gen_img, feed_dict={model.image:pimg, model.cond:pcond})
gen_img = gen_img.reshape(gen_img.shape[1:])
gen_img = (gen_img + 1.) * 127.5
image = np.concatenate((gen_img, cond), axis=1).astype(np.int)
imsave(image, "./test" + "/%d.jpg" % test_count)
imsave(image, "./test" + "/%d.jpg" % name)
if __name__ == "__main__":
test()
View
@@ -6,6 +6,7 @@
import tensorflow as tf
import numpy as np
import time
import sys
def prepocess_train(img, cond,):
img = scipy.misc.imresize(img, [conf.adjust_size, conf.adjust_size])
@@ -48,15 +49,17 @@ def train():
os.makedirs(conf.data_path + "/checkpoint")
if not os.path.exists(conf.output_path):
os.makedirs(conf.output_path)
with tf.Session() as sess:
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
with tf.Session(config=config) as sess:
if conf.model_path == "":
sess.run(tf.initialize_all_variables())
else:
saver.restore(sess, conf.model_path)
for epoch in xrange(conf.max_epoch):
train_data = data["train"]
for img, cond in train_data:
train_data = data["train"]()
for img, cond, name in train_data:
img, cond = prepocess_train(img, cond)
_, m = sess.run([d_opt, model.d_loss], feed_dict={model.image:img, model.cond:cond})
_, m = sess.run([d_opt, model.d_loss], feed_dict={model.image:img, model.cond:cond})
@@ -67,16 +70,17 @@ def train():
if (epoch + 1) % conf.save_per_epoch == 0:
save_path = saver.save(sess, conf.data_path + "/checkpoint/" + "model_%d.ckpt" % (epoch+1))
print "Model saved in file: %s" % save_path
test_data = data["test"]
test_count = 0
for img, cond in test_data:
test_count += 1
test_data = data["test"]()
for img, cond, name in test_data:
pimg, pcond = prepocess_test(img, cond)
gen_img = sess.run(model.gen_img, feed_dict={model.image:pimg, model.cond:pcond})
gen_img = gen_img.reshape(gen_img.shape[1:])
gen_img = (gen_img + 1.) * 127.5
image = np.concatenate((gen_img, cond), axis=1).astype(np.int)
imsave(image, conf.output_path + "/%d.jpg" % test_count)
imsave(image, conf.output_path + "/%d.jpg" % name)
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == 'gpu=':
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID" # see issue #152
os.environ["CUDA_VISIBLE_DEVICES"]=str(sys.argv[1][4:])
train()

0 comments on commit f519ef5

Please sign in to comment.