我正在运行一份旧代码库的Python代码,但似乎不再起作用,但我无法弄清原因或如何修复它。
安装代码(Google Colab笔记本)
#@title Setup
import pkg_resources
print(pkg_resources.get_distribution("torch").version)
from IPython.utils import io
with io.capture_output() as captured:
!git clone https://github.com/openai/CLIP
# !pip install taming-transformers
!git clone https://github.com/CompVis/taming-transformers.git
!rm -Rf clipit
!git clone https://github.com/mfrashad/clipit.git
!pip install ftfy regex tqdm omegaconf pytorch-lightning
!pip install kornia
!pip install imageio-ffmpeg
!pip install einops
!pip install torch-optimizer
!pip install easydict
!pip install braceexpand
!pip install git+https://github.com/pvigier/perlin-numpy
# ClipDraw deps
!pip install svgwrite
!pip install svgpathtools
!pip install cssutils
!pip install numba
!pip install torch-tools
!pip install visdom
!pip install gradio
!git clone https://github.com/BachiLi/diffvg
%cd diffvg
# !ls
!git submodule update --init --recursive
!python setup.py install
%cd ..
!mkdir -p steps
!mkdir -p models
import sys
sys.path.append("clipit")
然后在倒数第二行出现错误
import clipit
# To reset settings to default
clipit.reset_settings()
# You can use "|" to separate multiple prompts
prompts = "underwater city"
# You can trade off speed for quality: draft, normal, better, best
quality = "normal"
# Aspect ratio: widescreen, square
aspect = "widescreen"
# Add settings
clipit.add_settings(prompts=prompts, quality=quality, aspect=aspect)
# Apply these settings and run
settings = clipit.apply_settings()
clipit.do_init(settings) # generates error
clipit.do_run(settings)
使用形状为(1, 256, 16, 16) = 65536维的z。从taming/modules/autoencoder/lpips/vgg.pth加载预训练的LPIPS损失。VQLPIPSWithDiscriminator使用铰链损失运行。从models/vqgan_imagenet_f16_16384.ckpt恢复。在执行时发生错误:requires_grad_不支持ScriptModules。
AttributeError: 'RecursiveScriptModule' object has no attribute 'requires_grad'
。 - metalaureate