tsun / SSRT

Safe Self-Refinement for Transformer-based Domain Adaptation (CVPR 2022)
MIT License
39 stars 7 forks source link

Realize the adaptation of vision transformer to the confrontation domain #4

Closed fanbowen232218094636-spec closed 2 years ago

fanbowen232218094636-spec commented 2 years ago

Hello, nice to read your article! However, when I try to realize the combination of vision transformer and confrontation domain adaptation, I don't know a few points:

  1. About your division of data sets Txt file and train txt,test. Txt file is how to do it?

  2. I am running main ViT baseline. office_ home. The following error is reported during py. Do you know this?

    D:\Anaconda3\envs\torch1.10\python.exe D:/Codes/SSRT-master/main_ViT_baseline.office_home.py 2022-07-05 21.07.23:INFO: ++++++++++++++++++++++++++++++++++++++++++++++++
    --model=ViTgrl --base_net=vit_base_patch16_224 --gpu=0 --timestamp=2022-07-05_21.07.23 --dataset=Office-Home --source_path=data/Product.txt --target_path=data/Clipart.txt --batch_size=32 --lr=0.004 --train_epoch=20 --save_epoch=20 --eval_epoch=5 --iters_per_epoch=1000 --use_tensorboard=False --use_file_logger=True --log_dir=logs/ViTgrl
    ++++++++++++++++++++++++++++++++++++++++++++++++
    @LAPTOP-D8NJGV5D:29324

2022-07-05 21.07.23:INFO:Namespace(adap_adjust_L=4, adap_adjust_T=1000, adap_adjust_append_last_subintervals=True, adap_adjust_restore_optimizor=False, base_net='vit_base_patch16_224', batch_size=32, bottleneck_dim=2048, center_crop=False, class_num=65, classification_loss_weight=1.0, dataset='Office-Home', domain_loss_weight=1.0, eval_epoch=5, eval_source=True, eval_target=True, eval_test=True, gpu_id='0', iters_per_epoch=1000, log_dir='logs/ViTgrl', lr=0.004, lr_momentum=0.9, lr_scheduler_decay_rate=0.75, lr_scheduler_gamma=0.001, lr_scheduler_rate=1, lr_wd=0.0005, mi_loss_weight=0.0, model='ViTgrl', num_workers=4, rand_aug=False, random_resized_crop=False, random_seed=0, restore_checkpoint=None, save_checkpoint=True, save_epoch=20, source_path='data/Product.txt', sr_alpha=0.3, sr_epsilon=0.4, sr_layers=[0, 4, 8], sr_loss_p=0.5, sr_loss_weight=0.2, target_path='data/Clipart.txt', tensorboard_dir='tensorboard', test_path=None, timestamp='2022-07-05_21.07.23', train_epoch=20, use_bottleneck=True, use_file_logger=True, use_safe_training=False, use_tensorboard=False, writer=None) Traceback (most recent call last): File "D:\Codes\SSRT-master\trainer\train.py", line 183, in train_main model_instance = Model(base_net=args.base_net, bottleneck_dim=args.bottleneck_dim, use_gpu=True, class_num=args.class_num, args=args) File "D:\Codes\SSRT-master\model\ViTgrl.py", line 60, in init self.c_net = ViTgrlNet(base_net, args.use_bottleneck, bottleneck_dim, class_num, args) File "D:\Codes\SSRT-master\model\ViTgrl.py", line 13, in init self.base_network = vit_model[base_net](pretrained=True, args=args, VisionTransformerModule=VT) File "D:\Codes\SSRT-master\model\ViT.py", line 268, in vit_base_patch16_224 model = _create_vision_transformer('vit_base_patch16_224', pretrained=pretrained, model_kwargs) File "D:\Codes\SSRT-master\model\helpers.py", line 381, in _create_vision_transformer model = model_cls(img_size=img_size, num_classes=num_classes, distilled=distilled, kwargs) TypeError: init() got an unexpected keyword argument 'args'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "D:/Codes/SSRT-master/main_ViT_baseline.office_home.py", line 45, in train_main(args, header('\n\t\t'.join(args), hostName, pid)) File "D:\Codes\SSRT-master\trainer\train.py", line 185, in train_main raise NotImplementedError('Unsupported model') NotImplementedError: Unsupported model

Process finished with exit code 1

tsun commented 2 years ago

Hi, thanks for the comments.

  1. About your division of data sets Txt file and train txt,test. Txt file is how to do it? --> We follow the data set split as previous UDA works. DomainNet comes from its author (see http://ai.bu.edu/M3SDA/), where models are trained on _train split, and evaluated on _test split. For other datasets, models are trained and evaluated on the same split.

  2. I am running main ViT baseline. office_ home. The following error is reported during py. --> I have updated the code to fix this issue. It runs normally on our server now.

fanbowen232218094636-spec commented 2 years ago

Thank you very much for your reply. I'll continue to implement your code now, and hope to get through as soon as possible.