Skip to content

Commit

Permalink
Merge pull request #17 from RohanBhandari/master
Browse files Browse the repository at this point in the history
Edit to allow functionality with Octave
  • Loading branch information
xthan authored Jun 15, 2018
2 parents 8154533 + f842729 commit d61ab05
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 23 deletions.
Empty file added data/pose/.pose
Empty file.
Empty file added data/segment/.segment
Empty file.
Empty file added data/women_top/.women_top
Empty file.
Empty file added model/.model
Empty file.
2 changes: 1 addition & 1 deletion model_zalando_mask_content_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def main(unused_argv):
pass

# batch inference, can also be done one image per time.
batch_size = 16
batch_size = 1
image_holder = tf.placeholder(tf.float32, shape=[batch_size, 256, 192, 3])
prod_image_holder = tf.placeholder(
tf.float32, shape=[batch_size, 256, 192, 3])
Expand Down
2 changes: 1 addition & 1 deletion model_zalando_refine_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def main(unused_argv):
except:
pass

batch_size = 4
batch_size = 1

# Feed into the refine module
image_holder = tf.placeholder(tf.float32, shape=[batch_size,256,192,3])
Expand Down
6 changes: 0 additions & 6 deletions prepare_data/build_viton.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,7 @@ def _extract_pose_map(pose_keypoints, h, w):

def _process_segment_map(segment, h, w):
"""Extract segment maps."""
# Segment is a reversed 641x641 heat map (20 values).
segment = np.asarray(segment, dtype=np.uint8)
segment = np.transpose(segment)
if h > w:
segment = segment[:, :int(641.0 * float(w) / float(h))]
else:
segment = segment[:int(641.0 * float(h) / float(w)), :]
segment = imresize(segment, (h, w), interp='nearest')
return segment.tostring()

Expand Down
Empty file added results/.results
Empty file.
16 changes: 12 additions & 4 deletions shape_context_warp.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@
% Code for shape context matching (under shape_context folder) are modified from:
% https://www2.eecs.berkeley.edu/Research/Projects/CS/vision/shape/sc_digits.html


addpath('shape_context')
DATA_ROOT='data/women_top/';
MASK_DIR='results/stage1/tps/00015000_';

% Check if using MATLAB or Octave
isOctave = exist('OCTAVE_VERSION', 'builtin') ~= 0;
if(isOctave)
% Load image package for resizing images
pkg load image;
% Turn off warning
warning('off', 'Octave:possible-matlab-short-circuit-operator');
end

[image1, image2] = textread('data/viton_test_pairs.txt', '%s %s\n');
% using a smaller height and width for the shape context matching
% can save time without hurting the perform too much.
h = 256/4;
w = 192/4;
% we use 10x10 control_points
n_control = 10;
for i = 1:50 %length(image1) % only run for first 10 images
for i = 1:1 %length(image1) % only run over 1 image (for now)
image_name1 = image1{i};
image_name2 = image2{i};
if exist([MASK_DIR, image_name1, '_', image_name2, '_tps.mat'])
Expand Down Expand Up @@ -54,5 +62,5 @@
control_points = [x(point_index), y(point_index)]';
control_points = [control_points(1,:) / w; control_points(2,:) / h];
control_points = reshape(control_points, [2,n_control,n_control]);
save([MASK_DIR, image_name1, '_', image_name2, '_tps.mat'], 'control_points');
end
save([MASK_DIR, image_name1, '_', image_name2, '_tps.mat'], 'control_points', '-v6');
end
2 changes: 1 addition & 1 deletion test_stage1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ python model_zalando_mask_content_test.py \
--mode test \
--result_dir results/stage1/ \
--begin 0 \
--end 50
--end 1 #exclusive
2 changes: 1 addition & 1 deletion test_stage2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ python model_zalando_refine_test.py \
--mode test \
--result_dir results/stage2/ \
--begin 0 \
--end 50
--end 1 #exclusive
9 changes: 0 additions & 9 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,7 @@ def extract_segmentation(segment):

def process_segment_map(segment, h, w):
"""Extract segment maps."""
# Segment is a reversed 641x641 heat map (20 values).
segment = np.asarray(segment, dtype=np.uint8)
segment = np.transpose(segment)
if h > w:
segment = segment[:, :int(641.0 * float(w) / float(h))]
else:
segment = segment[:int(641.0 * float(h) / float(w)), :]
segment = imresize(segment, (h, w), interp='nearest')
return segment

Expand All @@ -107,9 +101,6 @@ def extract_pose_representation(pose_keypoints, h, w, resize_h, resize_w):
pose_keypoints = tf.cast(pose_keypoints, tf.int64)
# pose_representation = tf.zeros((h, w, 18))

# Fucking hard assignment!
# tf.nn.dilation2d

pose_representation = tf.one_hot(pose_keypoints, 3)
return pose_representation

Expand Down

0 comments on commit d61ab05

Please sign in to comment.