Commit 0c91dd65 authored by 李聪聪's avatar 李聪聪
Browse files

update readme

parent 1b2038e2
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
# Fun
 No newline at end of file
# Spatial Attention Pyramid Network for Unsupervised Domain Adaptation

## Introduction

This paper was accepted to ECCV 2020.

Unsupervised domain adaptation is critical in various computer vision tasks, such as object detection, instance segmentation, and semantic segmentation, which aims to alleviate performance degradation caused by domain-shift. Most of previous methods rely on a single-mode distribution of source and target domains to align them with adversarial learning, leading to inferior results in various scenarios. To that end, in this paper, we design a new spatial attention pyramid network for unsupervised domain adaptation. Specifically, we first build the spatial pyramid representation to capture context information of objects at different scales. Guided by the task-specific information, we combine the dense global structure representation and local texture patterns at each spatial location effectively using the spatial attention mechanism. In this way, the network is enforced to focus on the discriminative regions with context information for domain adaption. We conduct extensive experiments on various challenging datasets for unsupervised domain adaptation on object detection, instance segmentation, and semantic segmentation, which demonstrates that our method performs favorably against the state-of-the-art methods by a large margin.

![SAPNET](SAPNET.png)

SAPNET.png

0 → 100644
+430 KiB
Loading image diff...

a.py

deleted100644 → 0
+0 −21
Original line number Diff line number Diff line
import torch
import numpy as np
import matplotlib.pyplot as plt
from torch import nn
from torch.autograd import Variable
import torch.nn.functional as F
from functools import reduce, partial
from detection.layers import style_pool2d

if __name__ == '__main__':
    a = torch.randn(1, 32, 5, 5)

    y1 = style_pool2d(a, kernel_size=5)

    var, mean = torch.var_mean(a, dim=(2, 3), unbiased=False, keepdim=True)  # (n, c, new_h * new_w)
    std = torch.sqrt(var + 1e-12)

    windows = torch.cat((mean, std), dim=1)

    print(torch.allclose(y1, windows))
    print((y1 == windows))
+3 −3
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ def train_one_epoch(model, optimizer, train_loader, target_loader, device, epoch
                writer.add_scalar('lr', optimizer.param_groups[0]['lr'], global_step=global_step)
                writer.add_scalar('LAMBDA', LAMBDA, global_step=global_step)

        if global_step % (500 // max(1, (dist_utils.get_world_size() // 2))) == 0 and test_func is not None:
        if global_step % (2000 // max(1, (dist_utils.get_world_size() // 2))) == 0 and test_func is not None:
            updated = test_func()
            if updated:
                save_func('best.pth', 'mAP: {:.4f}'.format(best_mAP))
@@ -210,8 +210,8 @@ def main(cfg, args):
                for dataset_name, metric in metrics.items():
                    for k, v in metric.items():
                        metrics_writers[dataset_name].add_scalar('metrics/' + k, v, global_step=global_step)
                        if k == 'mAP' and v > best_mAP:
                        # if k == 'AP50' and v > best_mAP:
                        # if k == 'mAP' and v > best_mAP:
                        if k == 'AP' and v > best_mAP:
                            best_mAP = v
                            updated = True
            model.train()

adversarial_train_deprecated .py

deleted100644 → 0
+0 −878

File deleted.

Preview size limit exceeded, changes collapsed.

Loading