Update docs.

pull/1445/head
mzr1996 2023-03-20 16:10:33 +08:00
parent 1f78ab410f
commit 175d19f67e
2 changed files with 20 additions and 30 deletions

View File

@ -1,6 +1,6 @@
ARG PYTORCH="1.8.1" ARG PYTORCH="1.12.1"
ARG CUDA="10.2" ARG CUDA="11.3"
ARG CUDNN="7" ARG CUDNN="8"
FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel
@ -18,11 +18,9 @@ RUN apt-get update && apt-get install -y ffmpeg libsm6 libxext6 git ninja-build
# Install MMCV # Install MMCV
RUN pip install openmim RUN pip install openmim
RUN mim install mmengine "mmcv>=2.0rc0"
# Install MMClassification # Install MMClassification
RUN conda clean --all RUN conda clean --all
RUN git clone https://github.com/open-mmlab/mmclassification.git RUN git clone -b pretrain https://github.com/open-mmlab/mmclassification.git mmpretrain
WORKDIR ./mmclassification WORKDIR ./mmpretrain
RUN git checkout 1.x RUN mim install --no-cache-dir -e .
RUN pip install --no-cache-dir -e .

View File

@ -2,7 +2,7 @@
在本节中,我们将演示如何准备 PyTorch 相关的依赖环境。 在本节中,我们将演示如何准备 PyTorch 相关的依赖环境。
MMClassification 适用于 Linux、Windows 和 macOS。它需要 Python 3.7+、CUDA 9.2+ 和 PyTorch 1.6+。 MMPretrain 适用于 Linux、Windows 和 macOS。它需要 Python 3.7+、CUDA 10.2+ 和 PyTorch 1.8+。
```{note} ```{note}
如果你对配置 PyTorch 环境已经很熟悉,并且已经完成了配置,可以直接进入[下一节](#安装)。 如果你对配置 PyTorch 环境已经很熟悉,并且已经完成了配置,可以直接进入[下一节](#安装)。
@ -38,23 +38,23 @@ conda install pytorch torchvision cpuonly -c pytorch
# 安装 # 安装
我们推荐用户按照我们的最佳实践来安装 MMClassification。但除此之外如果你想根据 我们推荐用户按照我们的最佳实践来安装 MMPretrain。但除此之外如果你想根据
你的习惯完成安装流程,也可以参见[自定义安装](#自定义安装)一节来获取更多信息。 你的习惯完成安装流程,也可以参见[自定义安装](#自定义安装)一节来获取更多信息。
## 最佳实践 ## 最佳实践
根据具体需求,我们支持两种安装模式: 根据具体需求,我们支持两种安装模式:
- [从源码安装(推荐)](#从源码安装):希望基于 MMClassification 框架开发自己的图像分类任务,需要添加新的功能,比如新的模型或是数据集,或者使用我们提供的各种工具。 - [从源码安装(推荐)](#从源码安装):希望基于 MMPretrain 框架开发自己的预训练任务,需要添加新的功能,比如新的模型或是数据集,或者使用我们提供的各种工具。
- [作为 Python 包安装](#作为-python-包安装):只是希望调用 MMClassification 的 API 接口,或者在自己的项目中导入 MMClassification 中的模块。 - [作为 Python 包安装](#作为-python-包安装):只是希望调用 MMPretrain 的 API 接口,或者在自己的项目中导入 MMPretrain 中的模块。
### 从源码安装 ### 从源码安装
这种情况下,从源码按如下方式安装 mmpretrain 这种情况下,从源码按如下方式安装 mmpretrain
```shell ```shell
git clone -b 1.x https://github.com/open-mmlab/mmclassification.git git clone -b pretrain https://github.com/open-mmlab/mmclassification.git mmpretrain
cd mmclassification cd mmpretrain
pip install -U openmim && mim install -e . pip install -U openmim && mim install -e .
``` ```
@ -76,20 +76,12 @@ pip install -U openmim && mim install "mmpretrain>=1.0rc0"
## 验证安装 ## 验证安装
为了验证 MMClassification 的安装是否正确,我们提供了一些示例代码来执行模型推理。 为了验证 MMPretrain 的安装是否正确,我们提供了一些示例代码来执行模型推理。
**第 1 步** 我们需要下载配置文件和模型权重文件
```shell
mim download mmpretrain --config resnet50_8xb32_in1k --dest .
```
**第 2 步** 验证示例的推理流程
如果你是**从源码安装**的 mmpretrain那么直接运行以下命令进行验证 如果你是**从源码安装**的 mmpretrain那么直接运行以下命令进行验证
```shell ```shell
python demo/image_demo.py demo/demo.JPEG resnet50_8xb32_in1k.py resnet50_8xb32_in1k_20210831-ea4938fc.pth --device cpu python demo/image_demo.py demo/demo.JPEG resnet18_8xb32_in1k --device cpu
``` ```
你可以看到命令行中输出了结果字典,包括 `pred_label``pred_score` 和 `pred_class` 三个字段。 你可以看到命令行中输出了结果字典,包括 `pred_label``pred_score` 和 `pred_class` 三个字段。
@ -130,27 +122,27 @@ inference_model(model, 'demo/demo.JPEG')
### 在 CPU 环境中安装 ### 在 CPU 环境中安装
MMClassification 可以仅在 CPU 环境中安装,在 CPU 模式下,你可以完成训练、测试和模型推理等所有操作。 MMPretrain 可以仅在 CPU 环境中安装,在 CPU 模式下,你可以完成训练、测试和模型推理等所有操作。
### 在 Google Colab 中安装 ### 在 Google Colab 中安装
参考 [Colab 教程](https://colab.research.google.com/github/mzr1996/mmclassification-tutorial/blob/master/1.x/MMClassification_tools.ipynb) 安装即可。 参考 [Colab 教程](https://colab.research.google.com/github/mzr1996/mmclassification-tutorial/blob/master/1.x/MMClassification_tools.ipynb) 安装即可。
### 通过 Docker 使用 MMClassification ### 通过 Docker 使用 MMPretrain
MMClassification 提供 [Dockerfile](https://github.com/open-mmlab/mmclassification/blob/master/docker/Dockerfile) MMPretrain 提供 [Dockerfile](https://github.com/open-mmlab/mmclassification/blob/pretrain/docker/Dockerfile)
用于构建镜像。请确保你的 [Docker 版本](https://docs.docker.com/engine/install/) >=19.03。 用于构建镜像。请确保你的 [Docker 版本](https://docs.docker.com/engine/install/) >=19.03。
```shell ```shell
# 构建默认的 PyTorch 1.8.1CUDA 10.2 版本镜像 # 构建默认的 PyTorch 1.12.1CUDA 11.3 版本镜像
# 如果你希望使用其他版本,请修改 Dockerfile # 如果你希望使用其他版本,请修改 Dockerfile
docker build -t mmclassification docker/ docker build -t mmpretrain docker/
``` ```
用以下命令运行 Docker 镜像: 用以下命令运行 Docker 镜像:
```shell ```shell
docker run --gpus all --shm-size=8g -it -v {DATA_DIR}:/mmclassification/data mmclassification docker run --gpus all --shm-size=8g -it -v {DATA_DIR}:/mmpretrain/data mmpretrain
``` ```
## 故障解决 ## 故障解决