Skip to content

Commit

Permalink
Merge pull request modelscope#14 from modelscope/readme_refine
Browse files Browse the repository at this point in the history
refine readme and optimize requirements.txt
  • Loading branch information
wangxingjun778 authored Aug 14, 2023
2 parents d3f1205 + 1f6e92e commit 415e14d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 30 deletions.
60 changes: 39 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ FaceChain is powered by [ModelScope](https://github.com/modelscope/modelscope).
The following are the environment dependencies that have been verified:
- python: py3.8, py3.10
- pytorch: torch2.0.0, torch2.0.1
- tensorflow: 2.7.0, tensorflow-cpu
- tensorflow: 2.8.0, tensorflow-cpu
- CUDA: 11.7
- CUDNN: 8+
- OS: Ubuntu 20.04, CentOS 7.9
Expand All @@ -39,22 +39,19 @@ The following are the environment dependencies that have been verified:
The following installation methods are supported:


1. ModelScope notebook【recommended】
### 1. ModelScope notebook【recommended】

The ModelScope notebook has a free tier that allows you to run the FaceChain application, refer to [ModelScope Notebook](https://modelscope.cn/my/mynotebook/preset)

In addition to ModelScope notebook and ECS, I would suggest that we add that user may also start DSW instance with the option of ModelScope (GPU) image, to create a ready-to-use environment.

```shell
# Step1
我的notebook -> PAI-DSW -> GPU环境
# Step1: 我的notebook -> PAI-DSW -> GPU环境

# Step2
Open the Terminal,clone FaceChain from github:
# Step2: Open the Terminal,clone FaceChain from github:
GIT_LFS_SKIP_SMUDGE=1 git clone https://github.com/modelscope/facechain.git --depth 1

# Step3
Entry the Notebook cell:
# Step3: Entry the Notebook cell:
import os
os.chdir('/mnt/workspace/facechain')
print(os.getcwd())
Expand All @@ -63,33 +60,29 @@ print(os.getcwd())
!python3 app.py


# Step4
click "public URL" or "local URL"
# Step4: click "public URL" or "local URL", upload your images to
# train your own model and then generate your digital twin.
```


2. Docker
### 2. Docker

If you are familiar with using docker, we recommend to use this way:

```shell
# Step1
Prepare the environment with GPU on local or cloud, we recommend to use Alibaba Cloud ECS, refer to: https://www.aliyun.com/product/ecs
# Step1: Prepare the environment with GPU on local or cloud, we recommend to use Alibaba Cloud ECS, refer to: https://www.aliyun.com/product/ecs

# Step2
Download the docker image (for installing docker engine, refer to https://docs.docker.com/engine/install/)
# Step2: Download the docker image (for installing docker engine, refer to https://docs.docker.com/engine/install/)
docker pull registry.cn-hangzhou.aliyuncs.com/modelscope-repo/modelscope:ubuntu20.04-cuda11.7.1-py38-torch2.0.1-tf1.15.5-1.8.0

# Step3
docker images
docker run -it --name facechain -p 7860:7860 --gpus all your_xxx_image_id /bin/bash
# Step3: run the docker container
docker run -it --name facechain -p 7860:7860 --gpus all registry.cn-hangzhou.aliyuncs.com/modelscope-repo/modelscope:ubuntu20.04-cuda11.7.1-py38-torch2.0.1-tf1.15.5-1.8.0 /bin/bash
(Note: you may need to install the nvidia-container-runtime, refer to https://github.com/NVIDIA/nvidia-container-runtime)

# Step4
Install the gradio in the docker container:
# Step4: Install the gradio in the docker container:
pip3 install gradio

# Step5
# Step5 clone facechain from github
GIT_LFS_SKIP_SMUDGE=1 git clone https://github.com/modelscope/facechain.git --depth 1
cd facechain
python3 app.py
Expand All @@ -98,6 +91,31 @@ python3 app.py
Run the app server: click "public URL" --> in the form of: https://xxx.gradio.live
```

### 3. conda Virtual Environment

Use the conda virtual environment, and refer to [Anaconda](https://docs.anaconda.com/anaconda/install/) to manage your dependencies. After installation, execute the following commands:
(Note: mmcv has strict environment requirements and might not be compatible in some cases. It's recommended to use Docker.)

```shell
conda create -n facechain python=3.8 # Verified environments: 3.8 and 3.10
conda activate facechain

GIT_LFS_SKIP_SMUDGE=1 git clone https://github.com/modelscope/facechain.git --depth 1
cd facechain

pip3 install -r requirements.txt
pip3 install -U openmim
mim install mmcv-full==1.7.0

# Navigate to the facechain directory and run:
python3 app.py

# Finally, click on the URL generated in the log to access the web page.
```

**Note**: After the app service is successfully launched, go to the URL in the log, enter the "Image Customization" tab, click "Select Image to Upload", and choose at least one image with a face. Then, click "Start Training" to begin model training. After the training is completed, there will be corresponding displays in the log. Afterwards, switch to the "Image Experience" tab and click "Start Inference" to generate your own digital image.



# Script Execution

Expand Down
13 changes: 6 additions & 7 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ FaceChain的模型由[ModelScope](https://github.com/modelscope/modelscope)开
FaceChain是一个组合模型,使用了包括pytorch和tensorflow在内的机器学习框架,以下是已经验证过的主要环境依赖:
- python环境: py3.8, py3.10
- pytorch版本: torch2.0.0, torch2.0.1
- tensorflow版本: 2.7.0, tensorflow-cpu
- tensorflow版本: 2.8.0, tensorflow-cpu
- CUDA版本: 11.7
- CUDNN版本: 8+
- 操作系统版本: Ubuntu 20.04, CentOS 7.9
Expand All @@ -42,7 +42,7 @@ FaceChain是一个组合模型,使用了包括pytorch和tensorflow在内的机
## 安装指南
支持以下几种安装方式,任选其一:

1. 使用ModelScope提供的notebook环境【推荐】
### 1. 使用ModelScope提供的notebook环境【推荐】

ModelScope(魔搭社区)提供给新用户初始的免费计算资源,参考[ModelScope Notebook](https://modelscope.cn/my/mynotebook/preset)

Expand All @@ -68,7 +68,7 @@ print(os.getcwd())
```


2. docker镜像
### 2. docker镜像

如果您熟悉docker,可以使用我们提供的docker镜像,其包含了模型依赖的所有组件,无需复杂的环境安装:
```shell
Expand All @@ -79,9 +79,8 @@ print(os.getcwd())
# Step2: 将镜像下载到本地 (前提是已经安装了docker engine并启动服务,具体可参考: https://docs.docker.com/engine/install/)
docker pull registry.cn-hangzhou.aliyuncs.com/modelscope-repo/modelscope:ubuntu20.04-cuda11.7.1-py38-torch2.0.1-tf1.15.5-1.8.0

# Step3: 获取image id,并运行
docker images
docker run -it --name facechain -p 7860:7860 --gpus all your_xxx_image_id /bin/bash # 注意 your_xxx_image_id 替换成你的镜像id
# Step3: 拉起镜像运行
docker run -it --name facechain -p 7860:7860 --gpus all registry.cn-hangzhou.aliyuncs.com/modelscope-repo/modelscope:ubuntu20.04-cuda11.7.1-py38-torch2.0.1-tf1.15.5-1.8.0 /bin/bash # 注意 your_xxx_image_id 替换成你的镜像id
(注意: 如果提示无法使用宿主机GPU的错误,可能需要安装nvidia-container-runtime, 参考:https://github.com/NVIDIA/nvidia-container-runtime)

# Step4: 在容器中安装gradio
Expand All @@ -96,7 +95,7 @@ python3 app.py
```


3. conda虚拟环境
### 3. conda虚拟环境

使用conda虚拟环境,参考[Anaconda](https://docs.anaconda.com/anaconda/install/)来管理您的依赖,安装完成后,执行如下命令:
(提示: mmcv对环境要求较高,可能出现不适配的情况,推荐使用docker方式)
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ accelerate
transformers
diffusers
onnxruntime
modelscope[framework]
modelscope
Pillow
opencv-python
torchvision
mmdet==2.26.0
mmengine
tensorflow==2.7.0
tensorflow==2.8.0
#tensorflow-cpu # slower but no cuda conflicts
numpy==1.22.0
protobuf==3.20.1
Expand Down

0 comments on commit 415e14d

Please sign in to comment.