Skip to content
This repository has been archived by the owner on Feb 15, 2025. It is now read-only.

Commit

Permalink
remove unnecessaries
Browse files Browse the repository at this point in the history
  • Loading branch information
Dequan Wang committed Apr 15, 2021
1 parent fc5705f commit 7d236b4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 49 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This is the official project repository for [Tent: Fully-Test Time Adaptation by Entropy Minimization](https://openreview.net/forum?id=uXl3bZLkr3c) by
Dequan Wang\*, Evan Shelhamer\*, Shaoteng Liu, Bruno Olshausen, and Trevor Darrell (ICLR 2021, spotlight).

⛺️ Tent equips a model to adapt itself to new and different data during testing ☀️ 🌧❄️.
⛺️ Tent equips a model to adapt itself to new and different data during testing ☀️ 🌧 ❄️.
Tented models adapt online and batch-by-batch to reduce error on dataset shifts like corruptions, simulation-to-real discrepancies, and other differences between training and testing data.
This kind of adaptation is effective and efficient: tent makes just one update per batch to not interrupt inference.

Expand Down Expand Up @@ -49,7 +49,7 @@ If the tent method or fully test-time adaptation setting are helpful in your res
```bibtex
@inproceedings{wang2021tent,
title={Tent: Fully Test-Time Adaptation by Entropy Minimization},
author={Dequan Wang and Evan Shelhamer and Shaoteng Liu and Bruno Olshausen and Trevor Darrell},
author={Wang, Dequan and Shelhamer, Evan and Liu, Shaoteng and Olshausen, Bruno and Darrell, Trevor},
booktitle={International Conference on Learning Representations},
year={2021},
url={https://openreview.net/forum?id=uXl3bZLkr3c}
Expand Down
7 changes: 3 additions & 4 deletions cifar10c.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
logger = logging.getLogger(__name__)


def evaluate(cfg_file):
load_cfg_fom_args(cfg_file=cfg_file,
description="CIFAR-10-C evaluation.")
def evaluate(description):
load_cfg_fom_args(description)
# configure model
base_model = load_model(cfg.MODEL.ARCH, cfg.CKPT_DIR,
cfg.CORRUPTION.DATASET, ThreatModel.corruptions).cuda()
Expand Down Expand Up @@ -119,4 +118,4 @@ def setup_optimizer(params):


if __name__ == '__main__':
evaluate('cifar10c.yaml')
evaluate('"CIFAR-10-C evaluation.')
33 changes: 0 additions & 33 deletions cifar10c.yaml

This file was deleted.

14 changes: 5 additions & 9 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ def reset_cfg():
cfg.merge_from_other_cfg(_CFG_DEFAULT)


def load_cfg_fom_args(cfg_file='conf.yaml', description="Config options."):
def load_cfg_fom_args(description="Config options."):
"""Load config from command line args and set any specified options."""
current_time = datetime.now().strftime("%y%m%d_%H%M%S")
parser = argparse.ArgumentParser(description=description)
parser.add_argument("--cfg", dest="cfg_file", type=str, default=None,
parser.add_argument("--cfg", dest="cfg_file", type=str, required=True,
help="Config file location")
parser.add_argument("opts", default=None, nargs=argparse.REMAINDER,
help="See conf.py for all options")
Expand All @@ -178,15 +178,11 @@ def load_cfg_fom_args(cfg_file='conf.yaml', description="Config options."):
sys.exit(1)
args = parser.parse_args()

if args.cfg_file is None:
args.cfg_file = cfg_file
merge_from_file(args.cfg_file)
cfg.merge_from_list(args.opts)
if args.cfg_file == cfg_file:
log_dest = '{}_{}.txt'.format(cfg.CORRUPTION.MODEL, current_time)
else:
log_dest = os.path.basename(args.cfg_file)
log_dest = log_dest.replace('.yaml', '_{}.txt'.format(current_time))

log_dest = os.path.basename(args.cfg_file)
log_dest = log_dest.replace('.yaml', '_{}.txt'.format(current_time))

g_pathmgr.mkdirs(cfg.SAVE_DIR)
cfg.LOG_TIME, cfg.LOG_DEST = current_time, log_dest
Expand Down
2 changes: 1 addition & 1 deletion tent.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, model, optimizer, steps=1, episodic=False):

def forward(self, x):
if self.episodic:
self.reset(x)
self.reset()

for _ in range(self.steps):
outputs = forward_and_adapt(x, self.model, self.optimizer)
Expand Down

0 comments on commit 7d236b4

Please sign in to comment.