Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
Painter_pytorch
Commits
ac652aac
Commit
ac652aac
authored
Jun 18, 2024
by
Rayyyyy
Browse files
Modify README and dockerfile
parent
d461441a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
34 deletions
+17
-34
Contributors.md
Contributors.md
+2
-0
README.md
README.md
+14
-28
docker/Dockerfile
docker/Dockerfile
+1
-4
toy_datasets/coco/.DS_Store
toy_datasets/coco/.DS_Store
+0
-0
toy_datasets/coco/._.DS_Store
toy_datasets/coco/._.DS_Store
+0
-0
train.sh
train.sh
+0
-2
No files found.
Contributors.md
0 → 100644
View file @
ac652aac
# Contributors
None
\ No newline at end of file
README.md
View file @
ac652aac
...
@@ -3,20 +3,19 @@
...
@@ -3,20 +3,19 @@
[
Images Speak in Images: A Generalist Painter for In-Context Visual Learning
](
https://arxiv.org/abs/2212.02499
)
[
Images Speak in Images: A Generalist Painter for In-Context Visual Learning
](
https://arxiv.org/abs/2212.02499
)
## 模型结构
## 模型结构
整个模型基于VIT系列的骨干,VIT的backbone由encoder、decoder两部分组成, 编码器是由VIT的骨干block堆积而成,解码器其实是卷积层构成的。
<div
align=
center
>
<div
align=
center
>
<img
src=
"./doc/method.png"
/>
<img
src=
"./doc/method.png"
/>
</div>
</div>
## 算法原理
## 算法原理
将视觉任务的连续输出空间离散化, 并使用语言或专门设计的离散标记作为任务提示, 将视觉问题转化为 NLP 问题.
通用视觉模型 Painter , 将“以视觉为中心”作为建模核心思想,将图像作为输入和输出,从而获得上下文视觉信息,完成不同的视觉任务。将视觉任务的连续输出空间离散化, 并使用语言或专门设计的离散标记作为任务提示, 将视觉问题转化为 NLP 问题。
<div
align=
center
>
<div
align=
center
>
<img
src=
"./doc/progress.png"
/>
<img
src=
"./doc/progress.png"
/>
</div>
</div>
## 环境配置
## 环境配置
Tips: timm==0.3.2 版本存在
[
cannot import name 'container_abcs' from 'torch._six'
](
https://github.com/huggingface/pytorch-image-models/issues/420#issuecomment-776459842
)
问题, 需要将 timm/models/layers/helpers.py 中 from torch._six import container_abcs 修改为
Tips: timm==0.3.2 版本存在
[
cannot import name 'container_abcs' from 'torch._six'
](
https://github.com/huggingface/pytorch-image-models/issues/420#issuecomment-776459842
)
问题, 需要将
`
timm/models/layers/helpers.py
`
中
`
from torch._six import container_abcs
`
修改为
```
bash
```
bash
import torch
import torch
...
@@ -30,7 +29,6 @@ else:
...
@@ -30,7 +29,6 @@ else:
```
```
### Docker(方法一)
### Docker(方法一)
-v 路径、docker_name和imageID根据实际情况修改
-v 路径、docker_name和imageID根据实际情况修改
```
bash
```
bash
...
@@ -46,7 +44,6 @@ python -m pip install -e detectron2
...
@@ -46,7 +44,6 @@ python -m pip install -e detectron2
```
```
### Dockerfile(方法二)
### Dockerfile(方法二)
-v 路径、docker_name和imageID根据实际情况修改
-v 路径、docker_name和imageID根据实际情况修改
```
bash
```
bash
...
@@ -87,10 +84,9 @@ python -m pip install -e detectron2
...
@@ -87,10 +84,9 @@ python -m pip install -e detectron2
```
```
## 数据集
## 数据集
本项目所需数据集较多, 所以提供了项目数据集需求较多, 可以使用提供的
[
a toy training dataset
](
https://huggingface.co/BAAI/Painter/blob/main/toy_datasets.tar
)
数据集来验证部分功能, 数据集由每个类别中各10个类别组成. 将数据集放置于
`$Painter_ROOT/toy_datasets`
路径下, 并设置
`$Painter_ROOT/train_painter_vit_large.sh`
中
`DATA_PATH=toy_datasets`
即可, 其他参数请参考训练章节的介绍.
本项目所需数据集较多, 可以使用提供的
[
a toy training dataset
](
https://huggingface.co/BAAI/Painter/blob/main/toy_datasets.tar
)
数据集来验证部分功能, 数据集由每个类别中各10个类别组成. 将数据集放置于
`$Painter_ROOT/toy_datasets`
路径下, 并设置
`$Painter_ROOT/train_painter_vit_large.sh`
中
`DATA_PATH=toy_datasets`
即可, 其他参数请参考训练章节的介绍。
如需完整数据集, 请参考
[
data instructions
](
docs/DATA.md
)
.
完整数据集的目录结构如下:
如需完整数据集, 请参考
[
data instructions
](
docs/DATA.md
)
。
完整数据集的目录结构如下:
```
```
├── nyu_depth_v2/
├── nyu_depth_v2/
...
@@ -202,31 +198,27 @@ bash run_train_multi.sh
...
@@ -202,31 +198,27 @@ bash run_train_multi.sh
各个数据集推理方法如下:
各个数据集推理方法如下:
### NYU Depth V2
### NYU Depth V2
设置
`$Painter_ROOT/eval/nyuv2_depth/eval.sh`
文件里的
`JOB_NAME`
、
`PROMPT`
、
`CKPT_FILE`
和
`DATA_DIR`
参数,执行:
设置
`$Painter_ROOT/eval/nyuv2_depth/eval.sh`
文件里的
`JOB_NAME`
、
`PROMPT`
、
`CKPT_FILE`
和
`DATA_DIR`
参数:
```
bash
```
bash
bash
eval
/nyuv2_depth/eval.sh
bash
eval
/nyuv2_depth/eval.sh
```
```
### ADE20k Semantic Segmentation
### ADE20k Semantic Segmentation
1.
**无法使用 toy_datasets 进行验证**
;
1.
无法使用toy_datasets进行验证;
2.
设置
`$Painter_ROOT/eval/ade20k_semantic/eval.sh`
文件里的
`JOB_NAME`
、
`PROMPT`
参数, 执行下面的命令:
2.
设置
`$Painter_ROOT/eval/ade20k_semantic/eval.sh`
文件里的
`JOB_NAME`
、
`PROMPT`
参数, 执行下面的命令:
```
bash
```
bash
bash
eval
/ade20k_semantic/eval.sh
bash
eval
/ade20k_semantic/eval.sh
```
```
### COCO Panoptic Segmentation
### COCO Panoptic Segmentation
1.
**无法使用 toy_datasets 进行验证**
;
1.
无法使用toy_datasets进行验证;
2.
设置
`$Painter_ROOT/eval/coco_panoptic/eval.sh`
文件里的
`JOB_NAME`
、
`PROMPT`
参数, 然后执行下面的命令:
2.
设置
`$Painter_ROOT/eval/coco_panoptic/eval.sh`
文件里的
`JOB_NAME`
、
`PROMPT`
参数, 然后执行下面的命令:
```
bash
```
bash
bash
eval
/coco_panoptic/eval.sh
bash
eval
/coco_panoptic/eval.sh
```
```
### COCO Human Pose Estimation
### COCO Human Pose Estimation
1.
**无法使用 toy_datasets 进行验证**
;
1.
无法使用toy_datasets进行验证;
2.
生成验证所需的图像:
2.
生成验证所需的图像:
```
bash
```
bash
python
-m
torch.distributed.launch
--nproc_per_node
=
4
--master_port
=
29500
--use_env
eval
/mmpose_custom/painter_inference_pose.py
--ckpt_path
models/painter_vit_large/painter_vit_large.pth
python
-m
torch.distributed.launch
--nproc_per_node
=
4
--master_port
=
29500
--use_env
eval
/mmpose_custom/painter_inference_pose.py
--ckpt_path
models/painter_vit_large/painter_vit_large.pth
...
@@ -240,8 +232,6 @@ cd $Painter_ROOT/eval/mmpose_custom
...
@@ -240,8 +232,6 @@ cd $Painter_ROOT/eval/mmpose_custom
```
```
### Low-Light Image Enhancement
### Low-Light Image Enhancement
执行
```
bash
```
bash
python
eval
/lol/painter_inference_lol.py
--ckpt_path
models/path/of/painter_vit_large.pth
--data_dir
path/of/datasets
python
eval
/lol/painter_inference_lol.py
--ckpt_path
models/path/of/painter_vit_large.pth
--data_dir
path/of/datasets
...
@@ -250,24 +240,20 @@ python eval/lol/painter_inference_lol.py --ckpt_path models/painter_vit_large.pt
...
@@ -250,24 +240,20 @@ python eval/lol/painter_inference_lol.py --ckpt_path models/painter_vit_large.pt
```
```
## result
## result
三张图从左到右分别为: 原始图像, 低分辨率图像, 经模型超分处理后的图像。
三张图从左到右分别为: 原始图像, 低分辨率图像, 经模型超分处理后的图像.
<div
align=
center
>
<div
align=
center
>
<img
src=
"./doc/high.png"
/>
<img
src=
"./doc/high.png"
/>
<img
src=
"./doc/low.png"
/>
<img
src=
"./doc/low.png"
/>
<img
src=
"./doc/results.png"
/>
<img
src=
"./doc/results.png"
/>
</div>
</div>
### 精度
### 精度
基于项目提供的测试数据, 得到单卡测试结果如下:
基于项目提供的测试数据, 得到单卡测试结果如下:
| enhance | datasets | PSNR | SSIM |
| device | task | datasets | PSNR | SSIM |
| :------: | :------: | :------: | :------: |
| :------: | :------: | :------: | :------: | :------: |
| ours | LOL | 22.34 | 0.8716 |
| Z100L | enhance | LOL | 22.34 | 0.8716 |
| paper | LOL | 22.34 | 0.872 |
| paper | enhance | LOL | 22.34 | 0.872 |
## 应用场景
## 应用场景
### 算法类别
### 算法类别
...
...
docker/Dockerfile
View file @
ac652aac
FROM
image.sourcefind.cn:5000/dcu/admin/base/pytorch:1.13.1-centos7.6-dtk-23.04.1-py38-latest
FROM
image.sourcefind.cn:5000/dcu/admin/base/pytorch:1.13.1-centos7.6-dtk-23.04.1-py38-latest
RUN
source
/opt/dtk/env.sh
COPY
requirements.txt requirements.txt
RUN
pip3
install
-r
requirements.txt
toy_datasets/coco/.DS_Store
deleted
100644 → 0
View file @
d461441a
File deleted
toy_datasets/coco/._.DS_Store
deleted
100644 → 0
View file @
d461441a
File deleted
train.sh
View file @
ac652aac
...
@@ -6,8 +6,6 @@ export USE_MIOPEN_BATCHNORM=1
...
@@ -6,8 +6,6 @@ export USE_MIOPEN_BATCHNORM=1
DATA_PATH
=
/home/datasets
DATA_PATH
=
/home/datasets
name
=
painter_vit_large
name
=
painter_vit_large
python
-m
torch.distributed.launch
--nproc_per_node
=
4
\
python
-m
torch.distributed.launch
--nproc_per_node
=
4
\
--nnodes
=
${
WORLD_SIZE
}
--node_rank
=
$RANK
\
--master_addr
=
$MASTER_ADDR
--master_port
=
12358
\
--use_env
main_train.py
\
--use_env
main_train.py
\
--batch_size
2
\
--batch_size
2
\
--accum_iter
16
\
--accum_iter
16
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment