赞
踩
安装
Clone代码:
git clone https://github.com/lllyasviel/ControlNet.git
创建新的conda环境
- cd ControlNet
- # 创建虚拟环境
- conda env create -f environment.yaml
-
- # 激活环境
- conda activate control
安装xformer库
不安装报错,提示“No module ‘xformers’. Proceeding without it.”
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device(‘cpu’) to map your storages to the CPU.
pip install xformers
从Huggingface下载模型,放入相应文件夹
All models and detectors can be downloaded from our Hugging Face page. Make sure that SD models are put in "ControlNet/models" and detectors are put in "ControlNet/annotator/ckpts". Make sure that you download all necessary pretrained weights and detector models from that Hugging Face page, including HED edge detection model, Midas depth estimation model, Openpose, and so on.
理论上现在可以开始,运行各种模型
python gradio_canny2image.py
常见问题:
1.错误:
UserWarning: Failed to load image Python extension: libtorch_cuda_cu.so: cannot open shared object file: No such file or directory warn(f"Failed to load image Python extension: {e}")
新创建的环境torch、cuda驱动版本的不兼容问题
conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.7 -c pytorch -c nvidia
2.错误:future: <Task finished name='8suqwacq3hx_0' coro=<Queue.process_events() done, defined at /home/heyong/miniconda3/envs/control/lib/python3.8/site-packages/gradio/queueing.py:324> exception=AssertionError('No event data')>
assert data is not None, "No event data"
AssertionError: No event data
这问题可能是gradio版本问题,试试下面两种方法:
pip install gradio==3.38.0
- conda activate control
- python -m pip install --upgrade pip
- pip install gradio
3.查看torchvision版本是否兼容,可以用
- #进入python环境
- python
- #加载torchvision
- import torchvision
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。