If you want to use PyTorch C++ extensions:
deformable convolution: dcn for EDVR (For torchvision>=0.9.0, we use the official torchvision.ops.deform_conv2d
instead)
StyleGAN customized operators: upfirdn2d and fused_act for StyleGAN2
you also need to:
You may choose one of the options according to your needs.
Option | Pros | Cons | Cases | Env Variable |
---|---|---|---|---|
Compile PyTorch C++ extensions during installation | Quickly load the compiled extensions during running | May have more stringent requirements for the environment, and you may encounter annoying issues | If you need to train/inference those models for many times, it will save your time | Set BASICSR_EXT=True during installation |
Load PyTorch C++ extensions just-in-time (JIT) | Have less requirements, may have less issues | Each time you run the model, it will takes several minutes to load extensions again | If you just want to do simple inferences, it is more convenient | Set BASICSR_JIT=True during running (not installation) |
For those who need to compile the PyTorch C++ extensions during installation, remember:
Note that:
BASICSR_JIT
has higher priority, that is, even you have successfully compiled PyTorch C++ extensions during installation, it will still load the extensions just-in-time if you set BASICSR_JIT=True
in your running commands.BASICSR_JIT
during installation. Installation commands are in Installation Options.BASICSR_JIT=True
before your running commands. For example, BASICSR_JIT=True python inference/inference_stylegan2.py
.If you do not need those PyTorch C++ extensions, just skip it. There is no need to set BASICSR_EXT
or BASICSR_JIT
environment variables.
There are two options to install BASICSR, according to your needs.
If you do not need C++ extensions (more details are here):
pip install basicsr
If you want to use C++ extensions in JIT mode without compiling them during installatoin (more details are here):
pip install basicsr
If you want to compile C++ extensions during installation, please set the environment variable BASICSR_EXT=True
:
BASICSR_EXT=True pip install basicsr
The compilation may fail without any error prints. If you encounter running errors, such as ImportError: cannot import name 'deform_conv_ext' | 'fused_act_ext' | 'upfirdn2d_ext'
, you may check the compilation process by re-installation. The following command will print detailed log:
BASICSR_EXT=True pip install basicsr -vvv
You may also want to specify the CUDA paths:
CUDA_HOME=/usr/local/cuda \
CUDNN_INCLUDE_DIR=/usr/local/cuda \
CUDNN_LIB_DIR=/usr/local/cuda \
BASICSR_EXT=True pip install basicsr
Clone the repo
git clone https://github.com/xinntao/BasicSR.git
Install dependent packages
cd BasicSR
pip install -r requirements.txt
Install BasicSR
Please run the following commands in the BasicSR root path to install BasicSR:
If you do not need C++ extensions (more details are here):
python setup.py develop
If you want to use C++ extensions in JIT mode without compiling them during installatoin (more details are here):
python setup.py develop
If you want to compile C++ extensions during installation, please set the environment variable BASICSR_EXT=True
:
BASICSR_EXT=True python setup.py develop
You may also want to specify the CUDA paths:
CUDA_HOME=/usr/local/cuda \
CUDNN_INCLUDE_DIR=/usr/local/cuda \
CUDNN_LIB_DIR=/usr/local/cuda \
BASICSR_EXT=True python setup.py develop
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》