-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed Dataset for FSL step (filter not active yet) Fixed Word-Embeddings for SPNet in COCO
- Loading branch information
fcdl94
authored and
fcdl94
committed
Dec 29, 2020
1 parent
3ff19a3
commit 1ccd0ef
Showing
20 changed files
with
123,553 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,43 @@ | ||
#!/bin/bash | ||
|
||
export CUDA_VISIBLE_DEVICES=$1 | ||
port=$2 | ||
alias exp="python -m torch.distributed.launch --master_port ${port} --nproc_per_node=1 run.py --opt_level O0" | ||
alias exp="python -m torch.distributed.launch --master_port $2 --nproc_per_node=1 run.py --num_workers 8" | ||
shopt -s expand_aliases | ||
|
||
task=7mc | ||
ds=coco | ||
gen_par="--dataset coco --epochs 20 --batch_size 24 --crop_size 512 --val_interval 1" | ||
#gen_par="--task ${task} --dataset voc --epochs 30 --batch_size 24 --crop_size 512 --val_interval 1" | ||
#gen_par="--task voc --dataset coco-stuff --lr 0.01 --epochs 20 --batch_size 24 --crop_size 512 --val_interval 1" | ||
|
||
path=checkpoints/step/spn-${ds} | ||
lr=0.01 | ||
|
||
gen_par="--task ${task} --dataset ${ds} --batch_size 10 --crop_size 512" | ||
exp --method SPN --name SPN ${gen_par} --step 0 --lr ${lr} --task 20-0 | ||
exp --method SPN --name SPN ${gen_par} --step 0 --lr ${lr} --task 20-1 | ||
exp --method SPN --name SPN ${gen_par} --step 0 --lr ${lr} --task 20-2 | ||
|
||
lr=0.0001 # for 1-shot, 15-1 | ||
iter=200 | ||
|
||
for is in 0 1 2 3 4; do | ||
inc_par="--ishot ${is} --input_mix novel --val_interval 1000 --ckpt_interval 5 --no_pooling" | ||
for ns in 1; do | ||
exp --method AMP --name AMP --iter 0 --lr ${lr} ${gen_par} ${inc_par} --step 1 --nshot ${ns} --step_ckpt ${path}/FT_0.pth | ||
exp --method FT --name FT --iter ${iter} --lr ${lr} ${gen_par} ${inc_par} --step 1 --nshot ${ns} --step_ckpt ${path}/FT_0.pth | ||
for step in 2 3 4 5 6 7; do | ||
exp --method AMP --name AMP --iter 0 --lr ${lr} ${gen_par} ${inc_par} --step ${step} --nshot ${ns} | ||
exp --method FT --name FT --iter ${iter} --lr ${lr} ${gen_par} ${inc_par} --step ${step} --nshot ${ns} | ||
done | ||
done | ||
done | ||
#export CUDA_VISIBLE_DEVICES=$1 | ||
#port=$2 | ||
#alias exp="python -m torch.distributed.launch --master_port ${port} --nproc_per_node=1 run.py --opt_level O0" | ||
#shopt -s expand_aliases | ||
# | ||
#task=7mc | ||
#ds=coco | ||
# | ||
#path=checkpoints/step/spn-${ds} | ||
# | ||
#gen_par="--task ${task} --dataset ${ds} --batch_size 10 --crop_size 512" | ||
# | ||
#lr=0.0001 # for 1-shot, 15-1 | ||
#iter=200 | ||
# | ||
#for is in 0 1 2 3 4; do | ||
#inc_par="--ishot ${is} --input_mix novel --val_interval 1000 --ckpt_interval 5 --no_pooling" | ||
#for ns in 1; do | ||
# exp --method AMP --name AMP --iter 0 --lr ${lr} ${gen_par} ${inc_par} --step 1 --nshot ${ns} --step_ckpt ${path}/FT_0.pth | ||
# exp --method FT --name FT --iter ${iter} --lr ${lr} ${gen_par} ${inc_par} --step 1 --nshot ${ns} --step_ckpt ${path}/FT_0.pth | ||
# for step in 2 3 4 5 6 7; do | ||
# exp --method AMP --name AMP --iter 0 --lr ${lr} ${gen_par} ${inc_par} --step ${step} --nshot ${ns} | ||
# exp --method FT --name FT --iter ${iter} --lr ${lr} ${gen_par} ${inc_par} --step ${step} --nshot ${ns} | ||
# done | ||
# done | ||
#done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from PIL import Image | ||
import numpy as np | ||
import os | ||
import os.path as osp | ||
from tqdm import tqdm | ||
|
||
orig_path = '/dataset/vandal/COCO' # insert here the source path where original COCO annotations are | ||
dest_path = '.' # the destination folder, which should be this one' | ||
|
||
for split in ["train2017", "val2017"]: | ||
annotations = f"{orig_path}/annotations/{split}" | ||
nov_ann = f"{dest_path}/annotations/{split}" | ||
|
||
# clear folder if exists | ||
if osp.exists(nov_ann): | ||
print("Removing existing") | ||
os.rmdir(nov_ann) | ||
os.makedirs(nov_ann) | ||
|
||
# remap labels in the novel interval (+1 for Stuff, +1 and stuff on 0 for objects) | ||
mapping = np.zeros((256,), dtype=np.int8) | ||
for i, cl in enumerate(range(91)): | ||
mapping[cl] = i + 1 | ||
mapping[255] = 255 | ||
target_transform = lambda x: Image.fromarray(mapping[x]) | ||
|
||
for f in tqdm(os.listdir(annotations)): | ||
lbl = Image.open(osp.join(annotations, f)) | ||
lbl = target_transform(lbl) | ||
lbl.save(osp.join(nov_ann, f)) |
Binary file not shown.
File renamed without changes.
Oops, something went wrong.