Python中使用警告:UserWarning: loadtxt: Empty input file: “home******.txt“的解决方案

    技术2024-04-13  72

    问题描述:

    UserWarning: loadtxt: Empty input file: "/home/zh/PytorchProjects/00-DataSet/COCO2014/labels/train2014/COCO_train2014_000000195266.txt

    这只是一个使用警告,并不影响使用。警告loadtxt()函数可能读入空文件。

    解决方案:

    import warnings

    with warnings.catch_warnings():

           warnings.simplefilter('ignore')

           boxes = np.loadtxt(label_path)

     

    Processed: 0.014, SQL: 9