Resshift项目遇到的问题与解决

部署问题

下列问题的出现,源自readme.md文件中以下代码的执行。

conda create -n resshift python=3.10
conda activate resshift
pip install -r requirements.txt

问题1:NotImplementedError: No operator found for `memory_efficient_attention_forward` with inputs:

原因:

xformers使用的是cpu版本

 解决办法:

下载xformers的gpu版本(使用pip list 查询xformers版本号)

pip install -U xformers==0.0.23 --index-url https://download.pytorch.org/whl/cu118    

问题2:ERROR: No matching distribution found for scikit-image

原因:

scikit-image未安装

解决方法:

pip install scikit-image==版本号

或者

pip install -r requirements.txt

问题3:AssertionError: Torch not compiled with CUDA enabled

原因:

使用readme.md中的pip install -r requirements.txt会自动安装cpu版本的torchtorchvision

解决办法

方法一:自行对应torch和torchvision版本(该方法下载速度极慢)

pip uninstall torch
pip uninstall torchvision
pip install torch==2.1.1 torchvision==0.16.1 --index-url https://download.pytorch.org/whl/cu121

方法二:下载离线版gpu torch和torchvision

1、详细寻找合适版本torch.whl文件方法如下

torch版本下载地址:download.pytorch.org/whl

100%解决:AssertionError: Torch not compiled with CUDA enabled_raise assertionerror("torch not compiled with cuda-优快云博客https://blog.youkuaiyun.com/qq_45826605/article/details/138859427

2、找到合适版本的torch后,右键复制下载链接,打开以下网址转换成迅雷下载。

迅雷下载链接转换器 - Allen Zouhttps://www.allenzou.com/aztools/Commonly012.html

3、控制台进入虚拟环境中,cd到torch文件所在文件夹

pip install torch+xxxx.whl
pip install torchvision+xxxx.whl

问题4:RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

原因:

忘了

解决办法:

问题5:A matching Triton is not available, some optimizations will not be enabled. Error caught was: No module named 'triton'

原因:

解决方法:

详见

分析解决【No module named ‘triton‘】的问题_error caught was: no module named 'triton-优快云博客

运行问题

问题1:使用python inference_resshift.py 图像超分功能生成全黑的图片

示例代码:

python inference_resshift.py -i testdata/RealSet65/0014.jpg -o result/ --task realsr --scale 4

原因:

  • autoencoder(VQModelTorch类)
  •         encoder()方法
  •                 h = self.encoder(x) 段代码存在问题
(文件:ldm/modules/diffusionmodules/model.py)

for i_level in range(self.num_resolutions):
    for i_block in range(self.num_res_blocks[i_level]):
        h = self.down[i_level].block[i_block](hs[-1], temb)

第530行h出错(当i_level=2,i_block=0时,h中存在nan值)

解决方法:

文件:inference_resshift.py

修改:形参use_amp=False

resshift_sampler = ResShiftSampler(
            configs,
            sf=args.scale,
            chop_size=args.chop_size,
            chop_stride=chop_stride,
            chop_bs=1,
            use_amp=False,
            seed=args.seed,
            padding_offset=configs.model.params.get('lq_size', 64),
            )

### Diffusion模型的修复方法及其常见问题解决方案 #### 高清图像修复概述 Diffusion模型作为一种强大的生成工具,在高清图像修复领域展现了卓越的效果。这类模型通过逐步去噪过程,能够恢复被遮挡或损坏区域的真实细节[^1]。 #### 图像修复的具体流程 在实际操作中,Diffusion模型会经历如下阶段: - **初始化噪声注入**:给定一张带有缺失部分的目标图片,首先将其转化为完全随机化的噪音状态。 - **迭代反向传播**:随后按照预先定义的时间步长t逐渐减少噪声量级;每一步都会依据当前残差估计更新像素值直至接近原始清晰度水平。 - **最终输出预测**:当达到设定终点时停止演化并返回重构后的完整版影像文件。 ```python import torch from diffusers import StableDiffusionInpaintPipeline pipeline = StableDiffusionInpaintPipeline.from_pretrained( "runwayml/stable-diffusion-inpainting" ) image = pipeline(prompt="A beautiful landscape", image=init_image, mask_image=mask).images[0] ``` 此代码片段展示了如何利用预训练好的StableDiffusionInpaintPipeline来进行基于提示词的文字引导式修补工作。 #### 常见问题及对策分析 ##### 训练稳定性不足 由于扩散过程本质上是一个复杂的非线性映射关系构建任务,因此容易遭遇梯度消失/爆炸现象影响收敛速度质量。为此建议采用更稳健的学习率调度机制以及适当增加batch size规模来增强整体鲁棒特性[^2]。 ##### 多尺度适应难题 传统固定分辨率架构难以直接处理多变尺寸输入样本间的差异性特征表达需求。针对这一点可以通过引入连续域表示法——即所谓的“图像神经场”,使得网络具备跨层次泛化能力从而克服上述局限性。 ##### 效率优化瓶颈 标准DDPM框架下的采样环节往往耗时较长不利于实时应用场景部署实施。对此有学者提出了诸如ResShift等改进方案试图平衡计算成本同视觉效果之间的权衡取舍关系,旨在达成更快捷高效的重建目的而不明显损害画质表现力[^4]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值