在anaconda中使用labelimg标注数据集的问题

1.当我打开labelimg时,发现classes.txt文件不存在,报错FileNotFoundError: [Errno 2] No such file or directory: 'D:\\1\\train_label\\classes.txt'

(pytorch) D:\BaiduNetdiskDownload\weishi\HR_NoSC_data5\HR_NoSC_data5\1>labelimg
Traceback (most recent call last):
  File "E:\Python\Anaconda3\envs\pytorch\lib\site-packages\labelImg\labelImg.py", line 1378, in open_next_image
    self.load_file(filename)
  File "E:\Python\Anaconda3\envs\pytorch\lib\site-packages\labelImg\labelImg.py", line 1113, in load_file
    self.show_bounding_box_from_annotation_file(file_path)
  File "E:\Python\Anaconda3\envs\pytorch\lib\site-packages\labelImg\labelImg.py", line 1146, in show_bounding_box_from_annotation_file
    self.load_yolo_txt_by_filename(txt_path)
  File "E:\Python\Anaconda3\envs\pytorch\lib\site-packages\labelImg\labelImg.py", line 1559, in load_yolo_txt_by_filename
    t_yolo_parse_reader = YoloReader(txt_path, self.image)
  File "E:\Python\Anaconda3\envs\pytorch\lib\site-packages\libs\yolo_io.py", line 100, in __init__
    classes_file = open(self.class_list_path, 'r')
FileNotFoundError: [Errno 2] No such file or directory: 'D:\\BaiduNetdiskDownload\\weishi\\HR_NoSC_data5\\HR_NoSC_data5\\1\\train_label\\classes.txt'

我存放文件的路径如下,非常正常,而它报错显示classes.txt应该放在label文件夹里,好怪,先试试怎么改,再把classes.txt放到那个文件夹里吧

 尝试1:

打开labelimg安装文件夹:E:\Python\Anaconda3\envs\pytorch\Lib\site-packages\labelImg,找到labelimg.py文件

修改

def __init__(self, default_filename=None, default_prefdef_class_file=None, default_save_dir=None):

def __init__(self, default_filename=None, default_prefdef_class_file= '/classes的绝对路径/classes.txt' , default_save_dir=None):

并添加一行代码

default_prefdef_class_file = 'D:/BaiduNetdiskDownload/weishi/HR_NoSC_data5/HR_NoSC_data5/1/classes.txt'

 最终结果如下

    #def __init__(self, default_filename=None, default_prefdef_class_file=None, default_save_dir=None):
    def __init__(self, default_filename=None, default_prefdef_class_file= 'D:/BaiduNetdiskDownload/weishi/HR_NoSC_data5/HR_NoSC_data5/1/classes.txt' , default_save_dir=None):

        super(MainWindow, self).__init__()
        self.setWindowTitle(__appname__)

        default_prefdef_class_file = 'D:/BaiduNetdiskDownload/weishi/HR_NoSC_data5/HR_NoSC_data5/1/classes.txt'

 继续打开labelimg,失败

解决:问题2的解决方法

2.创建新标注时,闪退报错IndexError: list index out of range

Traceback (most recent call last):
  File "E:\Python\Anaconda3\envs\pytorch\Lib\site-packages\labelImg\labelImg.py", line 1381, in open_next_image
    self.load_file(filename)
  File "E:\Python\Anaconda3\envs\pytorch\Lib\site-packages\labelImg\labelImg.py", line 1116, in load_file
    self.show_bounding_box_from_annotation_file(file_path)
  File "E:\Python\Anaconda3\envs\pytorch\Lib\site-packages\labelImg\labelImg.py", line 1149, in show_bounding_box_from_annotation_file
    self.load_yolo_txt_by_filename(txt_path)
  File "E:\Python\Anaconda3\envs\pytorch\Lib\site-packages\labelImg\labelImg.py", line 1562, in load_yolo_txt_by_filename
    t_yolo_parse_reader = YoloReader(txt_path, self.image)
  File "E:\Python\Anaconda3\envs\pytorch\lib\site-packages\libs\yolo_io.py", line 112, in __init__
    self.parse_yolo_format()
  File "E:\Python\Anaconda3\envs\pytorch\lib\site-packages\libs\yolo_io.py", line 143, in parse_yolo_format
    label, x_min, y_min, x_max, y_max = self.yolo_line_to_shape(class_index, x_center, y_center, w, h)
  File "E:\Python\Anaconda3\envs\pytorch\lib\site-packages\libs\yolo_io.py", line 125, in yolo_line_to_shape
    label = self.classes[int(class_index)]
IndexError: list index out of range

解决: 在anaconda终端中输入如下命令,它同时解决了问题1,2

labelimg D:\BaiduNetdiskDownload\weishi\HR_NoSC_data5\HR_NoSC_data5\1\train_image(图片路径) D:\BaiduNetdiskDownload\weishi\HR_NoSC_data5\HR_NoSC_data5\1\classes.txt(classes.txt路径)

参考labelimg 修正模型错误标注遇到的问题

3.Flie list 变成独立窗口

手欠点了右上角的框框,File list变成独立窗口回不去了

                   

解决: 双击“File List” 就能变回原样

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值