Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52759e3
commit 6b532e3
Showing
400 changed files
with
18,081 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -------------------------------------------------------- | ||
# Domain Adaptation | ||
# Written by VARMS | ||
# -------------------------------------------------------- |
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,50 @@ | ||
import os | ||
import datasets.list_loader as list_loader | ||
import torch | ||
from torchvision import transforms | ||
import lib.utils as utils | ||
from lib.config import cfg | ||
import torch.distributed as dist | ||
from os.path import join as join | ||
|
||
|
||
def get_transform(): | ||
trans = [] | ||
|
||
if cfg.AUG.RESIZE[0] > 0 and cfg.AUG.RESIZE[1] > 0: | ||
trans.append(transforms.Resize(cfg.AUG.RESIZE)) | ||
if cfg.AUG.V_FLIP > 0: | ||
trans.append(transforms.RandomVerticalFlip(p=cfg.AUG.V_FLIP)) | ||
if cfg.AUG.H_FLIP > 0: | ||
trans.append(transforms.RandomHorizontalFlip(p=cfg.AUG.H_FLIP)) | ||
if cfg.AUG.ROTATION > 0: | ||
trans.append(transforms.RandomRotation(cfg.AUG.ROTATION, expand=False)) | ||
if cfg.AUG.BRIGHTNESS > 0 or cfg.AUG.CONTRAST > 0 or cfg.AUG.SATURATION > 0 or cfg.AUG.HUE > 0: | ||
trans.append(transforms.ColorJitter(brightness=cfg.AUG.BRIGHTNESS, | ||
contrast=cfg.AUG.CONTRAST, saturation=cfg.AUG.SATURATION, hue=cfg.AUG.HUE)) | ||
if cfg.AUG.RND_CROP[0] > 0 and cfg.AUG.RND_CROP[1] > 0: | ||
trans.append(transforms.RandomCrop(cfg.AUG.RND_CROP)) | ||
|
||
trans.append(transforms.ToTensor()) | ||
trans.append(transforms.Normalize(cfg.MEAN, cfg.STD)) | ||
return trans | ||
|
||
|
||
def load_test(target_root, test_label, use_mirror = False): | ||
if use_mirror: | ||
transform = transforms.Compose([ | ||
transforms.RandomHorizontalFlip(p=1.0), | ||
transforms.Resize(cfg.AUG.TEST_CROP), | ||
transforms.ToTensor(), | ||
transforms.Normalize(cfg.MEAN, cfg.STD) | ||
]) | ||
else: | ||
transform = transforms.Compose([ | ||
transforms.Resize(cfg.AUG.TEST_CROP), | ||
transforms.ToTensor(), | ||
transforms.Normalize(cfg.MEAN, cfg.STD) | ||
]) | ||
image_set = list_loader.ListLoader(target_root, test_label, transform) | ||
loader = torch.utils.data.DataLoader(image_set, batch_size=cfg.TEST.BATCH_SIZE, | ||
shuffle=False, num_workers=cfg.DATA_LOADER.NUM_WORKERS) | ||
return loader |
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,43 @@ | ||
import torch | ||
import torch.utils.data as data | ||
from PIL import Image | ||
import os | ||
import random | ||
import numpy as np | ||
from lib.config import cfg | ||
|
||
|
||
def default_loader(path): | ||
return Image.open(path).convert('RGB') | ||
|
||
|
||
def make_dataset(root, list_path): | ||
images = [] | ||
listtxt = open(list_path) | ||
for line in listtxt: | ||
data = line.strip().split(' ') | ||
path = os.path.join(root, data[0]) | ||
label = int(data[1]) | ||
item = (path, label) | ||
images.append(item) | ||
return images | ||
|
||
|
||
class ListLoader(data.Dataset): | ||
def __init__(self, root, list_path, transform=None, loader=default_loader): | ||
imgs = make_dataset(root, list_path) | ||
self.root = root | ||
self.imgs = imgs | ||
self.transform = transform | ||
self.loader = loader | ||
|
||
def __getitem__(self, index): | ||
path, target = self.imgs[index] | ||
img = self.loader(path) | ||
|
||
if self.transform is not None: | ||
img = self.transform(img) | ||
return img, target | ||
|
||
def __len__(self): | ||
return len(self.imgs) |
43 changes: 43 additions & 0 deletions
43
ExtractFeat/experiments/phase1/clipart/efficientnet_b4/efficientnet_b4_clipart/config.yml
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,43 @@ | ||
LOGGER_NAME: 'log' | ||
SEED: 1546884941.160048 | ||
############################ TRAIN ############################ | ||
TRAIN: | ||
FIX_TWO: True | ||
|
||
############################ TEST ############################ | ||
TEST: | ||
BATCH_SIZE: 32 | ||
|
||
############################ DATA_LOADER ############################ | ||
DATA_LOADER: | ||
NUM_WORKERS: 4 | ||
SHUFFLE: True | ||
DATA_ROOT: '../dataset/visda2019' | ||
LIST: 'list' | ||
FOLDER: 'clipart' | ||
|
||
############################ AUG ############################ | ||
AUG: | ||
TEST_CROP: [320, 320] | ||
#TEST_CROP: [288, 288] | ||
RESIZE: [0, 0] | ||
RND_CROP: [0, 0] | ||
|
||
V_FLIP: 0.0 | ||
H_FLIP: 0.5 | ||
ROTATION: 0.0 | ||
BRIGHTNESS: 0.0 | ||
CONTRAST: 0.0 | ||
SATURATION: 0.0 | ||
HUE: 0.0 | ||
MULTI_CROP_SIZE: 0 | ||
|
||
MEAN: [0.485, 0.456, 0.406] | ||
STD: [0.229, 0.224, 0.225] | ||
|
||
############################ MODEL ############################ | ||
MODEL: | ||
CLASS_NUM: 345 | ||
NET: 'efficientnet_b4' | ||
IN_DIM: 1792 | ||
EMBED_DIM: 1000 |
43 changes: 43 additions & 0 deletions
43
ExtractFeat/experiments/phase1/clipart/efficientnet_b4/efficientnet_b4_infograph/config.yml
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,43 @@ | ||
LOGGER_NAME: 'log' | ||
SEED: 1546884941.160048 | ||
############################ TRAIN ############################ | ||
TRAIN: | ||
FIX_TWO: True | ||
|
||
############################ TEST ############################ | ||
TEST: | ||
BATCH_SIZE: 32 | ||
|
||
############################ DATA_LOADER ############################ | ||
DATA_LOADER: | ||
NUM_WORKERS: 4 | ||
SHUFFLE: True | ||
DATA_ROOT: '../dataset/visda2019' | ||
LIST: 'list' | ||
FOLDER: 'infograph' | ||
|
||
############################ AUG ############################ | ||
AUG: | ||
TEST_CROP: [320, 320] | ||
#TEST_CROP: [288, 288] | ||
RESIZE: [0, 0] | ||
RND_CROP: [0, 0] | ||
|
||
V_FLIP: 0.0 | ||
H_FLIP: 0.5 | ||
ROTATION: 0.0 | ||
BRIGHTNESS: 0.0 | ||
CONTRAST: 0.0 | ||
SATURATION: 0.0 | ||
HUE: 0.0 | ||
MULTI_CROP_SIZE: 0 | ||
|
||
MEAN: [0.485, 0.456, 0.406] | ||
STD: [0.229, 0.224, 0.225] | ||
|
||
############################ MODEL ############################ | ||
MODEL: | ||
CLASS_NUM: 345 | ||
NET: 'efficientnet_b4' | ||
IN_DIM: 1792 | ||
EMBED_DIM: 1000 |
43 changes: 43 additions & 0 deletions
43
ExtractFeat/experiments/phase1/clipart/efficientnet_b4/efficientnet_b4_quickdraw/config.yml
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,43 @@ | ||
LOGGER_NAME: 'log' | ||
SEED: 1546884941.160048 | ||
############################ TRAIN ############################ | ||
TRAIN: | ||
FIX_TWO: True | ||
|
||
############################ TEST ############################ | ||
TEST: | ||
BATCH_SIZE: 32 | ||
|
||
############################ DATA_LOADER ############################ | ||
DATA_LOADER: | ||
NUM_WORKERS: 4 | ||
SHUFFLE: True | ||
DATA_ROOT: '../dataset/visda2019' | ||
LIST: 'list' | ||
FOLDER: 'quickdraw' | ||
|
||
############################ AUG ############################ | ||
AUG: | ||
TEST_CROP: [320, 320] | ||
#TEST_CROP: [288, 288] | ||
RESIZE: [0, 0] | ||
RND_CROP: [0, 0] | ||
|
||
V_FLIP: 0.0 | ||
H_FLIP: 0.5 | ||
ROTATION: 0.0 | ||
BRIGHTNESS: 0.0 | ||
CONTRAST: 0.0 | ||
SATURATION: 0.0 | ||
HUE: 0.0 | ||
MULTI_CROP_SIZE: 0 | ||
|
||
MEAN: [0.485, 0.456, 0.406] | ||
STD: [0.229, 0.224, 0.225] | ||
|
||
############################ MODEL ############################ | ||
MODEL: | ||
CLASS_NUM: 345 | ||
NET: 'efficientnet_b4' | ||
IN_DIM: 1792 | ||
EMBED_DIM: 1000 |
43 changes: 43 additions & 0 deletions
43
ExtractFeat/experiments/phase1/clipart/efficientnet_b4/efficientnet_b4_real/config.yml
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,43 @@ | ||
LOGGER_NAME: 'log' | ||
SEED: 1546884941.160048 | ||
############################ TRAIN ############################ | ||
TRAIN: | ||
FIX_TWO: True | ||
|
||
############################ TEST ############################ | ||
TEST: | ||
BATCH_SIZE: 32 | ||
|
||
############################ DATA_LOADER ############################ | ||
DATA_LOADER: | ||
NUM_WORKERS: 4 | ||
SHUFFLE: True | ||
DATA_ROOT: '../dataset/visda2019' | ||
LIST: 'list' | ||
FOLDER: 'real' | ||
|
||
############################ AUG ############################ | ||
AUG: | ||
TEST_CROP: [320, 320] | ||
#TEST_CROP: [288, 288] | ||
RESIZE: [0, 0] | ||
RND_CROP: [0, 0] | ||
|
||
V_FLIP: 0.0 | ||
H_FLIP: 0.5 | ||
ROTATION: 0.0 | ||
BRIGHTNESS: 0.0 | ||
CONTRAST: 0.0 | ||
SATURATION: 0.0 | ||
HUE: 0.0 | ||
MULTI_CROP_SIZE: 0 | ||
|
||
MEAN: [0.485, 0.456, 0.406] | ||
STD: [0.229, 0.224, 0.225] | ||
|
||
############################ MODEL ############################ | ||
MODEL: | ||
CLASS_NUM: 345 | ||
NET: 'efficientnet_b4' | ||
IN_DIM: 1792 | ||
EMBED_DIM: 1000 |
43 changes: 43 additions & 0 deletions
43
ExtractFeat/experiments/phase1/clipart/efficientnet_b4/efficientnet_b4_sketch/config.yml
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,43 @@ | ||
LOGGER_NAME: 'log' | ||
SEED: 1546884941.160048 | ||
############################ TRAIN ############################ | ||
TRAIN: | ||
FIX_TWO: True | ||
|
||
############################ TEST ############################ | ||
TEST: | ||
BATCH_SIZE: 32 | ||
|
||
############################ DATA_LOADER ############################ | ||
DATA_LOADER: | ||
NUM_WORKERS: 4 | ||
SHUFFLE: True | ||
DATA_ROOT: '../dataset/visda2019' | ||
LIST: 'list' | ||
FOLDER: 'sketch' | ||
|
||
############################ AUG ############################ | ||
AUG: | ||
TEST_CROP: [320, 320] | ||
#TEST_CROP: [288, 288] | ||
RESIZE: [0, 0] | ||
RND_CROP: [0, 0] | ||
|
||
V_FLIP: 0.0 | ||
H_FLIP: 0.5 | ||
ROTATION: 0.0 | ||
BRIGHTNESS: 0.0 | ||
CONTRAST: 0.0 | ||
SATURATION: 0.0 | ||
HUE: 0.0 | ||
MULTI_CROP_SIZE: 0 | ||
|
||
MEAN: [0.485, 0.456, 0.406] | ||
STD: [0.229, 0.224, 0.225] | ||
|
||
############################ MODEL ############################ | ||
MODEL: | ||
CLASS_NUM: 345 | ||
NET: 'efficientnet_b4' | ||
IN_DIM: 1792 | ||
EMBED_DIM: 1000 |
43 changes: 43 additions & 0 deletions
43
ExtractFeat/experiments/phase1/clipart/efficientnet_b5/efficientnet_b5_clipart/config.yml
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,43 @@ | ||
LOGGER_NAME: 'log' | ||
SEED: 1546884941.160048 | ||
############################ TRAIN ############################ | ||
TRAIN: | ||
FIX_TWO: True | ||
|
||
############################ TEST ############################ | ||
TEST: | ||
BATCH_SIZE: 32 | ||
|
||
############################ DATA_LOADER ############################ | ||
DATA_LOADER: | ||
NUM_WORKERS: 4 | ||
SHUFFLE: True | ||
DATA_ROOT: '../dataset/visda2019' | ||
LIST: 'list' | ||
FOLDER: 'clipart' | ||
|
||
############################ AUG ############################ | ||
AUG: | ||
TEST_CROP: [320, 320] | ||
#TEST_CROP: [288, 288] | ||
RESIZE: [0, 0] | ||
RND_CROP: [0, 0] | ||
|
||
V_FLIP: 0.0 | ||
H_FLIP: 0.5 | ||
ROTATION: 0.0 | ||
BRIGHTNESS: 0.0 | ||
CONTRAST: 0.0 | ||
SATURATION: 0.0 | ||
HUE: 0.0 | ||
MULTI_CROP_SIZE: 0 | ||
|
||
MEAN: [0.485, 0.456, 0.406] | ||
STD: [0.229, 0.224, 0.225] | ||
|
||
############################ MODEL ############################ | ||
MODEL: | ||
CLASS_NUM: 345 | ||
NET: 'efficientnet_b5' | ||
IN_DIM: 2048 | ||
EMBED_DIM: 1000 |
Oops, something went wrong.