Permalink
Browse files

roou

  • Loading branch information...
Ireneruru committed Feb 19, 2017
1 parent 12b899e commit ea2afeebedd20be9ffead30b7e17af01fc78000b
Showing with 616 additions and 0 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. +133 −0 .idea/workspace.xml
  7. +16 −0 config.py
  8. +22 −0 data.py
  9. +66 −0 model.py
  10. +176 −0 roou.py
  11. +52 −0 test.py
  12. +82 −0 train.py
  13. +40 −0 utils.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
@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="d3d74cac-ec78-4747-baf2-6a1f7af63848" name="Default" comment="">
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/vcs.xml" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="CreatePatchCommitExecutor">
<option name="PATCH_PATH" value="" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="model.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/model.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="e#0#33#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectFrameBounds">
<option name="width" value="1440" />
<option name="height" value="900" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
<manualOrder />
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scratches" />
<pane id="ProjectPane">
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="GalaxyGAN_python" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="GalaxyGAN_python" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="FullScreen" value="true" />
</component>
<component name="ShelveChangesManager" show_recycled="false">
<option name="remove_strategy" value="false" />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="d3d74cac-ec78-4747-baf2-6a1f7af63848" name="Default" comment="" />
<created>1487517864576</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1487517864576</updated>
</task>
<servers />
</component>
<component name="ToolWindowManager">
<frame x="0" y="0" width="1440" height="900" extended-state="0" />
<editor active="false" />
<layout>
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.114869624" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/model.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="e#0#33#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>
View
@@ -0,0 +1,16 @@
class Config:
data_path = "./datasets/facades"
model_path = ""#"./datasets/facades/checkpoint/model_100.ckpt"
output_path = "./results"
img_size = 256
adjust_size = 286
train_size = 256
img_channel = 3
conv_channel_base = 64
learning_rate = 0.0002
beta1 = 0.5
max_epoch = 200
L1_lambda = 100
save_per_epoch=5
View
22 data.py
@@ -0,0 +1,22 @@
from config import Config as conf
from utils import imread
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
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")
return data
View
@@ -0,0 +1,66 @@
from config import Config as conf
from utils import conv2d, deconv2d, linear, batch_norm, lrelu
import tensorflow as tf
class CGAN(object):
def __init__(self):
self.image = tf.placeholder(tf.float32, shape=(1,conf.img_size, conf.img_size, conf.img_channel))
self.cond = tf.placeholder(tf.float32, shape=(1,conf.img_size, conf.img_size, conf.img_channel))
self.gen_img = self.generator(self.cond)
pos = self.discriminator(self.image, self.cond, False)
neg = self.discriminator(self.gen_img, self.cond, True)
pos_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(pos, tf.ones_like(pos)))
neg_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(neg, tf.zeros_like(neg)))
self.d_loss = pos_loss + neg_loss
self.g_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(neg, tf.ones_like(neg))) + \
conf.L1_lambda * tf.reduce_mean(tf.abs(self.image - self.gen_img))
t_vars = tf.trainable_variables()
self.d_vars = [var for var in t_vars if 'disc' in var.name]
self.g_vars = [var for var in t_vars if 'gen' in var.name]
def discriminator(self, img, cond, reuse):
dim = len(img.get_shape())
with tf.variable_scope("disc", reuse=reuse):
image = tf.concat(dim - 1, [img, cond])
feature = conf.conv_channel_base
h0 = lrelu(conv2d(image, feature, name="h0"))
h1 = lrelu(batch_norm(conv2d(h0, feature*2, name="h1"), "h1"))
h2 = lrelu(batch_norm(conv2d(h1, feature*4, name="h2"), "h2"))
h3 = lrelu(batch_norm(conv2d(h2, feature*8, name="h3"), "h3"))
h4 = linear(tf.reshape(h3, [1,-1]), 1, "linear")
return h4
def generator(self, cond):
with tf.variable_scope("gen"):
feature = conf.conv_channel_base
e1 = conv2d(cond, feature, name="e1")
e2 = batch_norm(conv2d(lrelu(e1), feature*2, name="e2"), "e2")
e3 = batch_norm(conv2d(lrelu(e2), feature*4, name="e3"), "e3")
e4 = batch_norm(conv2d(lrelu(e3), feature*8, name="e4"), "e4")
e5 = batch_norm(conv2d(lrelu(e4), feature*8, name="e5"), "e5")
e6 = batch_norm(conv2d(lrelu(e5), feature*8, name="e6"), "e6")
e7 = batch_norm(conv2d(lrelu(e6), feature*8, name="e7"), "e7")
e8 = batch_norm(conv2d(lrelu(e7), feature*8, name="e8"), "e8")
d1 = deconv2d(tf.nn.relu(e8), [1,2,2,feature*8], name="d1")
d1 = tf.concat(3, [tf.nn.dropout(batch_norm(d1, "d1"), 0.5), e7])
d2 = deconv2d(tf.nn.relu(d1), [1,4,4,feature*8], name="d2")
d2 = tf.concat(3, [tf.nn.dropout(batch_norm(d2, "d2"), 0.5), e6])
d3 = deconv2d(tf.nn.relu(d2), [1,8,8,feature*8], name="d3")
d3 = tf.concat(3, [tf.nn.dropout(batch_norm(d3, "d3"), 0.5), e5])
d4 = deconv2d(tf.nn.relu(d3), [1,16,16,feature*8], name="d4")
d4 = tf.concat(3, [batch_norm(d4, "d4"), e4])
d5 = deconv2d(tf.nn.relu(d4), [1,32,32,feature*4], name="d5")
d5 = tf.concat(3, [batch_norm(d5, "d5"), e3])
d6 = deconv2d(tf.nn.relu(d5), [1,64,64,feature*2], name="d6")
d6 = tf.concat(3, [batch_norm(d6, "d6"), e2])
d7 = deconv2d(tf.nn.relu(d6), [1,128,128,feature], name="d7")
d7 = tf.concat(3, [batch_norm(d7, "d7"), e1])
d8 = deconv2d(tf.nn.relu(d7), [1,256,256,conf.img_channel], name="d8")
return tf.nn.tanh(d8)
Oops, something went wrong.

0 comments on commit ea2afee

Please sign in to comment.