我正在从一个旧的存储库运行 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")
Run Code Online (Sandbox Code Playgroud)
然后是倒数第二个错误
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)
Run Code Online (Sandbox Code Playgroud)
使用形状为 (1, 256, 16, 16) = 65536 维的 z。从 taming/modules/autoencoder/lpips/vgg.pth VQLPIPSWithDiscriminator 加载预训练的 LPIPS 损失,以铰链损失运行。从 models/vqgan_imagenet_f16_16384.ckpt 恢复 ---------------------------------------------------------- -------------------------------- RuntimeError Traceback(最近一次调用最后一次) in () 12 # 应用这些设置并运行13 设置 = Clipit.apply_settings() ---> 14 Clipit.do_init(settings) 15 Clipit.do_run(settings)
1 帧 /usr/local/lib/python3.7/dist-packages/torch/jit/_script.py 中的失败(self,*args,**kwargs)912 def _make_fail(名称):913 def失败(self,* args, **kwargs): --> 914 raise RuntimeError(name + " 脚本模块不支持") 915 916 返回失败
运行时错误:ScriptModules 不支持 require_grad_
对于遇到此问题的任何不幸的灵魂,此 URL 拯救了我的灵魂
https://github.com/mfrashad/text2art/issues/5
Run Code Online (Sandbox Code Playgroud)