<p align="center">
<img width="150" alt="logo" src="https://i.imgur.com/0OaOlKO.png">
</p>
# Progressive Semantic Segmentation (MagNet)
[](https://colab.research.google.com/drive/1WTdfIQIEQrnoX40YIzs3HqeIKSZD_iPG?usp=sharing) [](https://arxiv.org/abs/2104.03778) [](https://youtu.be/40Kw8QLym7E)
[**MagNet**](https://github.com/VinAIResearch/MagNet), a multi-scale framework that resolves local ambiguity by looking at the image at multiple magnification levels, has multiple processing stages, where each stage corresponds to a magnification level, and the output of one stage is fed into the next stage for coarse-to-fine information propagation. Experiments on three high-resolution datasets of urban views, aerial scenes, and medical images show that MagNet consistently outperforms the state-of-the-art methods by a significant margin.

Details of the MagNet model architecture and experimental results can be found in our [following paper](https://arxiv.org/abs/2104.03778):
```
@inproceedings{m_Huynh-etal-CVPR21,
author = {Chuong Huynh and Anh Tran and Khoa Luu and Minh Hoai},
title = {Progressive Semantic Segmentation},
year = {2021},
booktitle = {Proceedings of the {IEEE} Conference on Computer Vision and Pattern Recognition (CVPR)},
}
```
**Please CITE** our paper when MagNet is used to help produce published results or incorporated into other software.
## Datasets
This current code provides configurations to train, evaluate on two datasets: **Cityscapes** and **DeepGlobe**. To prepare the datasets, in the `./data` directory, please do following steps:
### For Cityscapes
1. Register an account on this [page](https://www.cityscapes-dataset.com/) and log in.
2. Download `leftImg8bit_trainvaltest.zip` and `gtFine_trainvaltest.zip`.
3. Run the script below to extract zip files to correct locations:
```bash
sh ./prepare_cityscapes.sh
```
### For DeepGlobe
1. Register an account on this [page](https://competitions.codalab.org/competitions/18468) and log in.
2. Go to this [page]() and download **Starting Kit** of the `#1 Development` Phase.
3. Run the script below to extract zip files to correct locations:
```bash
sh ./prepare_deepglobe.sh
```
If you want to train/evaluate with your dataset, follow the steps in this [document](CUSTOM_DATA.md)
## Getting started
### Requirements
The framework is tested on machines with the following environment:
- Python >= 3.6
- CUDA >= 10.0
To install dependencies, please run the following command:
```bash
pip install -r requirements.txt
```
### Pretrained models
Performance of pre-trained models on datasets:
| Dataset | Backbone | Baseline IoU (%) | MagNet IoU (%) | MagNet-Fast IoU (%) | Download |
| -------- | -------- | -------- | -------- | -------- | -------- |
| Cityscapes | HRNetW18+OCR | 63.24 | 68.20 | 67.37 |[backbone](https://public.vinai.io/magnet_cvpr2021/cityscapes_hrnet.pth)<br>[refine_512x256](https://public.vinai.io/magnet_cvpr2021/cityscapes_refinement_512.pth)<br>[refine_1024x512](https://public.vinai.io/magnet_cvpr2021/cityscapes_refinement_1024.pth)<br>[refine_2048x1024](https://public.vinai.io/magnet_cvpr2021/cityscapes_refinement_2048.pth) |
| DeepGlobe | Resnet50-FPN | 67.22 | 72.10 | 68.22 | [backbone](https://public.vinai.io/magnet_cvpr2021/deepglobe_fpn.pth)<br>[refine](https://public.vinai.io/magnet_cvpr2021/deepglobe_refinement.pth)
Please manually download pre-trained models to `./checkpoints` or run the script below:
```bash
cd checkpoints
sh ./download_cityscapes.sh # for Cityscapes
# or
sh ./download_deepglobe.sh # for DeepGlobe
```
### Usage
You can run this [Google Colab Notebook](https://colab.research.google.com/drive/1WTdfIQIEQrnoX40YIzs3HqeIKSZD_iPG?usp=sharing) to test our pre-trained models with street-view images. Please follow the instructions in the notebook to experience the performance of our network.
If you want to test our framework on your local machine:
1. To test with a Cityscapes image, e.g `data/frankfurt_000001_003056_leftImg8bit.png`:
- With MagNet refinement:
```bash
python demo.py --dataset cityscapes \
--image data/frankfurt_000001_003056_leftImg8bit.png \
--scales 256-128,512-256,1024-512,2048-1024 \
--crop_size 256 128 \
--input_size 256 128 \
--model hrnet18+ocr \
--pretrained checkpoints/cityscapes_hrnet.pth \
--pretrained_refinement checkpoints/cityscapes_refinement_512.pth checkpoints/cityscapes_refinement_1024.pth checkpoints/cityscapes_refinement_2048.pth \
--num_classes 19 \
--n_points 32768 \
--n_patches -1 \
--smooth_kernel 5 \
--save_pred \
--save_dir test_results/demo
# or in short, you can run
sh scripts/cityscapes/demo_magnet.sh data/frankfurt_000001_003056_leftImg8bit.png
```
- With MagNet-Fast refinement
```bash
python demo.py --dataset cityscapes \
--image frankfurt_000001_003056_leftImg8bit.png \
--scales 256-128,512-256,1024-512,2048-1024 \
--crop_size 256 128 \
--input_size 256 128 \
--model hrnet18+ocr \
--pretrained checkpoints/cityscapes_hrnet.pth \
--pretrained_refinement checkpoints/cityscapes_refinement_512.pth checkpoints/cityscapes_refinement_1024.pth checkpoints/cityscapes_refinement_2048.pth \
--num_classes 19 \
--n_points 0.9 \
--n_patches 4 \
--smooth_kernel 5 \
--save_pred \
--save_dir test_results/demo
# or in short, you can run
sh scripts/cityscapes/demo_magnet_fast.sh data/frankfurt_000001_003056_leftImg8bit.png
```
All results will be stored at `test_results/demo/frankfurt_000001_003056_leftImg8bit`
2. To test with a Deepglobe image, e.g `data/639004_sat.jpg`:
- With MagNet refinement:
```bash
python demo.py --dataset deepglobe \
--image data/639004_sat.jpg \
--scales 612-612,1224-1224,2448-2448 \
--crop_size 612 612 \
--input_size 508 508 \
--model fpn \
--pretrained checkpoints/deepglobe_fpn.pth \
--pretrained_refinement checkpoints/deepglobe_refinement.pth \
--num_classes 7 \
--n_points 0.75 \
--n_patches -1 \
--smooth_kernel 11 \
--save_pred \
--save_dir test_results/demo
# or in short, you can run
sh scripts/deepglobe/demo_magnet.sh data/639004_sat.jpg
```
- With MagNet-Fast refinement
```bash
python demo.py --dataset deepglobe \
--image data/639004_sat.jpg \
--scales 612-612,1224-1224,2448-2448 \
--crop_size 612 612 \
--input_size 508 508 \
--model fpn \
--pretrained checkpoints/deepglobe_fpn.pth \
--pretrained_refinement checkpoints/deepglobe_refinement.pth \
--num_classes 7 \
--n_points 0.9 \
--n_patches 3 \
--smooth_kernel 11 \
--save_pred \
--save_dir test_results/demo
# or in short, you can run
sh scripts/deepglobe/demo_magnet_fast.sh data/639004_sat.jpg
```
All results will be stored at `test_results/demo/639004_sat`
## Training
### Training backbone networks
We customize the training script from [HRNet repository](https://github.com/HRNet/HRNet-Semantic-Segmentation) to train our backbones. Please first go to this directory `./backbone` and run the following scripts:
#### HRNetW18V2+OCR for Cityscapes
Download pre-trained weights on ImageNet:
```
# In ./backbone
cd pretrained_wei
MagNet-main, 是一种用于生成对抗网络(GAN)训练的模型,主要用来提升生成图像的质量并解决生成模型中存在的一些挑战,...
需积分: 0 162 浏览量
更新于2024-11-30
收藏 4.47MB ZIP 举报
MagNet 的优点
生成质量提高:
通过改进的训练过程和对抗训练策略,MagNet 可以生成质量更高、更加多样化的图像。
稳定性:
解决了常见的训练不稳定性问题,相比于传统的 GAN 模型,MagNet 在训练过程中更加鲁棒。
灵活性:
MagNet 的设计可能允许在不同的生成任务中灵活应用,具有很好的适应性。
MagNet-main是一个专门针对生成对抗网络(GAN)提出的训练模型,它的主要目标是解决传统GAN在图像生成过程中遇到的若干问题,包括但不限于模式崩溃和训练不稳定等。在GAN训练中,通常存在生成器和判别器两个主要部分,它们通过不断的对抗过程来提升图像生成的质量。MagNet-main在此基础上,通过一系列优化策略,显著提升了生成图像的质量,同时确保了训练过程的稳定性。
在MagNet-main的助力下,生成的图像质量得到了大幅度提高。这一成果主要得益于模型对训练过程的精细调控,这包括对抗训练策略的创新应用。对抗训练是指在训练过程中,生成器和判别器互相学习,不断调整自身策略以达到更加复杂的平衡。MagNet-main通过这种训练方式,能够生成更加精细、丰富和多样化的图像。
此外,MagNet-main在训练稳定性上表现出色。传统GAN模型在训练过程中经常会出现模式崩溃的问题,即生成器陷入某一特定模式,无法生成多样化的图像。而MagNet-main通过引入新的技术手段和优化算法,有效避免了训练过程中出现的这些问题,使得训练过程更加鲁棒,无论是在数据集较大或是较小时,都能够保持良好的训练效果。
MagNet-main的灵活性也是一大亮点。设计的灵活性意味着MagNet-main不仅仅局限于某一种特定的生成任务,它可以根据不同的需求进行调整和优化,从而在各种不同的生成任务中都有所作为。这种灵活性的来源,一方面是MagNet-main在结构设计上的考量,使其能够轻松适配多种应用场景;另一方面,MagNet-main在训练策略上也提供了足够的自由度,让用户能够针对特定任务进行调优。
从整体上看,MagNet-main模型针对GAN训练中的核心挑战,提供了一套行之有效的解决方案。通过提升图像生成质量、确保训练的稳定性,并保持了足够的灵活性,MagNet-main不仅推动了GAN技术的发展,也为图像生成领域带来了一定的革新。随着相关技术的进一步研究和完善,MagNet-main有望在更多领域内展示其潜力,特别是在那些对图像质量有着严格要求的领域,如游戏开发、电影特效以及虚拟现实等。

墨迪大大
- 粉丝: 0
最新资源
- 毕设&课设:智慧笔匠在线文档 第十三届“中国软件杯”大学生软件设计大赛 A10 在线编辑器赛道一等奖作品.zip
- 毕设&课设:智慧工地设计方案.zip
- 毕设&课设:智慧记单词,本科Android课程设计.zip
- 毕设&课设:智慧党建项目-中铁一局集团第五工程有限公司-中国兵器工业集团特种能源集团-中铁第一勘察设计院城建院-.zip
- Delphi 12 控件之Delphi-获得打印机列表&打印机状态&打印机详细信息源代码
- 毕设&课设:智慧社区党建积分——毕业设计Android端.zip
- 毕设&课设:智慧零工平台前端系统是一个基于uni-app框架开发的跨平台移动端应用,支持微信小程序和H5双端运行.zip
- 毕设&课设:智慧社区居家养老健康管理系统,计算机毕业设计,毕设,Java毕业设计,SpringBoot,SSM,.zip
- 毕设&课设:智慧社团(毕业设计).zip
- 毕设&课设:智慧外贸平台,计算机毕业设计,毕设,Java毕业设计,SpringBoot,SSM,小程序,Java.zip
- 毕设&课设:智慧图书管理系统设计与实现,计算机毕业设计,毕设,Java毕业设计,SpringBoot,SSM,小.zip
- 毕设&课设:智慧物业平台修改5.5小程序,计算机毕业设计,毕设,Java毕业设计,SpringBoot,SSM,.zip
- 毕设&课设:智慧物业平台小程序,计算机毕业设计,毕设,Java毕业设计,SpringBoot,SSM,小程序,J.zip
- 毕设&课设:智慧物流小程序,计算机毕业设计,毕设,Java毕业设计,SpringBoot,SSM,小程序,Jav.zip
- 毕设&课设:智慧校园云端管理系统的设计和实现.zip
- 毕设&课设:智慧校园管理系统小程序,计算机毕业设计,毕设,Java毕业设计,SpringBoot,SSM,小程序.zip