相关Warning及Error收集(一)

Warning1:RandomContrast

FutureWarning: RandomContrast has been deprecated. Please use RandomBrightnessContrast

解决办法:

A.RandomContrast(p=0.5),

改为

A.RandomBrightnessContrast(p=0.5),

或者不用管它。

Error1:freeze_support()

RuntimeError: 
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

解决办法:
num_workers=1改为num_workers=0或者把这个参数删掉最简单。
参考pytorch使用出现"RuntimeError: An attempt has been made to start a new process before the…" 解决方法_MaloFleur的博客-CSDN博客

Error2:global loadsave

[ WARN:0@7.094] global loadsave.cpp:248 cv::findDecoder imread_('./农民身份识别挑战赛公开数据/train\u95XbY6HHt.jpg'): can't open/read file: check file path/integrity

解决办法:
因为路径名带有中文。
将文件夹重新命名即可,记得代码里面的路径也要一起改了。

Warning2:positional parameter

UserWarning: Using 'weights' as positional parameter(s) is deprecated since 0.13 and may be removed in the future. Please use keyword parameter(s) instead.
  warnings.warn(

UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing `weights=ResNet18_Weights.IMAGENET1K_V1`. You can also use `weights=ResNet18_Weights.DEFAULT` to get the most up-to-date weights.
  warnings.warn(msg)

解决办法:

model = models.resnet18(pretrained=True)

改为

`model = models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1)`

参考博客【PyTorch教程】04-详解torchvision 0.13中的预训练模型加载的更新及报错的解决方法 (2022年最新)_升级torchvision_自牧君的博客-CSDN博客

Error3:is not defined

    end = time.time()
NameError: name 'time' is not defined

解决办法:
可能代码里忘了导入time。
在开头加一句

import time

即可。

猜你喜欢

转载自blog.csdn.net/U202113837/article/details/132115082