Skip to content

Commit 9537598

Browse files
fix data transform crop x y inversed bug
1 parent 8735ecb commit 9537598

File tree

4 files changed

+24
-27
lines changed

4 files changed

+24
-27
lines changed

core/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __call__(self, img, alpha, fg, bg, trimap, crop_h, crop_w):
3939
cropx, cropy = 0, 0
4040
if len(target[0]) > 0:
4141
rand_ind = np.random.randint(len(target[0]), size = 1)[0]
42-
cropx, cropy = target[0][rand_ind], target[1][rand_ind]
42+
cropy, cropx = target[0][rand_ind], target[1][rand_ind]
4343
cropx = min(max(cropx, 0), w - crop_w)
4444
cropy = min(max(cropy, 0), h - crop_h)
4545

core/train.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def main():
339339

340340
# training
341341
for epoch in range(start_epoch, args.nEpochs + 1):
342-
#train(args, model, optimizer, train_loader, epoch)
342+
train(args, model, optimizer, train_loader, epoch)
343343
if epoch > 0 and epoch % args.ckptSaveFreq == 0:
344344
checkpoint(epoch, args.saveDir, model)
345345
if epoch > 0 and args.testFreq > 0 and epoch % args.testFreq == 0:

deploy.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
#/bin/bash
22

3-
DESKTOP=/home/liuliang/Desktop
4-
MODEL_ROOT=$DESKTOP/pytorch-deep-image-matting-pure
5-
DATA_ROOT=$DESKTOP/dataset/matting/dataset_deep_image_matting/Test_set
3+
TEST_DATA_ROOT=/data/datasets/matting/Combined_Dataset/Test_set/comp
64

75
python core/deploy.py \
86
--size_h=320 \
97
--size_w=320 \
10-
--imgDir=$DATA_ROOT/comp/image \
11-
--trimapDir=$DATA_ROOT/comp/trimap \
12-
--alphaDir=$DATA_ROOT/comp/alpha \
13-
--saveDir=$MODEL_ROOT/result/batch1_stage1_cktp_e22 \
14-
--resume=$MODEL_ROOT/model/batch1_stage0_ckpt_e22.pth \
8+
--imgDir=$TEST_DATA_ROOT/image \
9+
--trimapDir=$TEST_DATA_ROOT/trimap \
10+
--alphaDir=$TEST_DATA_ROOT/alpha \
11+
--saveDir=result/stage0 \
12+
--resume=model/stage0/ckpt_e19.pth \
1513
--cuda \
1614
--stage=0 \
1715
--crop_or_resize=whole \

train.sh

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
#/bin/bash
2-
DESKTOP=/home/liuliang/Desktop
3-
ROOT=$DESKTOP/pytorch-deep-image-matting-pure
4-
DATA_ROOT=$DESKTOP/dataset/matting
5-
TRAIN_DATA_ROOT=$DATA_ROOT/dataset_deep_image_matting/Training_set
6-
TEST_DATA_ROOT=$DESKTOP/dataset/matting/dataset_deep_image_matting/Test_set
2+
DATA_ROOT=/data/datasets/matting/Combined_Dataset
3+
TRAIN_DATA_ROOT=$DATA_ROOT/Training_set/comp
4+
TEST_DATA_ROOT=$DATA_ROOT/Test_set/comp
75

86
python core/train.py \
97
--crop_h=320,480,640 \
108
--crop_w=320,480,640 \
119
--size_h=320 \
1210
--size_w=320 \
13-
--alphaDir=$TRAIN_DATA_ROOT/comp/alpha \
14-
--fgDir=$TRAIN_DATA_ROOT/comp/fg \
15-
--bgDir=$TRAIN_DATA_ROOT/comp/bg \
16-
--imgDir=$TRAIN_DATA_ROOT/comp/image \
17-
--saveDir=$ROOT/model/stage0 \
11+
--alphaDir=$TRAIN_DATA_ROOT/alpha \
12+
--fgDir=$TRAIN_DATA_ROOT/fg \
13+
--bgDir=$TRAIN_DATA_ROOT/bg \
14+
--imgDir=$TRAIN_DATA_ROOT/image \
15+
--saveDir=model/stage0 \
1816
--batchSize=1 \
19-
--nEpochs=50 \
17+
--nEpochs=25 \
2018
--step=-1 \
2119
--lr=0.00001 \
2220
--wl_weight=0.5 \
2321
--threads=4 \
24-
--printFreq=50 \
22+
--printFreq=1 \
2523
--ckptSaveFreq=1 \
2624
--cuda \
2725
--stage=0 \
2826
--pretrain=model/vgg_state_dict.pth \
2927
--testFreq=1 \
30-
--testImgDir=$TEST_DATA_ROOT/comp/image \
31-
--testTrimapDir=$TEST_DATA_ROOT/comp/trimap \
32-
--testAlphaDir=$TEST_DATA_ROOT/comp/alpha \
33-
--testResDir=$ROOT/result/tmp \
28+
--testImgDir=$TEST_DATA_ROOT/image \
29+
--testTrimapDir=$TEST_DATA_ROOT/trimap \
30+
--testAlphaDir=$TEST_DATA_ROOT/alpha \
31+
--testResDir=result/tmp \
3432
--crop_or_resize=whole \
35-
--max_size=320
33+
--max_size=1600
34+
#--resume=model/stage0/ckpt_e6.pth \

0 commit comments

Comments
 (0)