1.YOLOX无法指定gpu,只能指定gpu个数
YOLOX-main/yolox/utils/dist.py在此路径下注释和添加代码:

def get_local_rank() -> int: ###############ori
"""
Returns:
The rank of the current process within the local (per-machine) process group.
"""
if not dist.is_available():
return 0
if not dist.is_initialized():
return 0
assert _LOCAL_PROCESS_GROUP is not None
return dist.get_rank(group=_LOCAL_PROCESS_GROUP) ###############ori
def get_local_rank() -> int: ##########add
"""
Returns:
The rank of the current process within the local (per-machine) process group.
"""
if not dist.is_available():
return select_device('2')
if not dist.is_initialized():
return select_device('2')
assert _LOCAL_PROCESS_GROUP is not None
return dist.get_rank(group=_LOCAL_PROCESS_GROUP)
def select_device(device=''):
# device = 'cpu' or '0' or '0,1,2,3'
cpu_request = device.lower() == 'cpu'
if device and not cpu_request: # if device requested other than 'cpu'
os.environ['CUDA_VISIBLE_DEVICES'] = device # set environment variable
assert torch.cuda.is_available(), 'CUDA unavailable, invalid device %s requested' % device # check availablity
cuda = False if cpu_request else torch.cuda.is_available()
return 0 if cuda else 'cpu' ##########add
2.训练时候突然多出其他类别
yolox训练时候突然多出两类,莫名其妙??

检查标签发现貌似没问题,一共7类

后面查看json文件发现中间的标签,由于中间有空格,所以一类变成三类,突然多出两类

后面修正一下标签如下,加下划线_

3. 负样本生成txt
当加入负样本时候,生成空的txt,放进去训练
import os.path
import cv2
from tqdm import tqdm
path = r"F:\1213bag\bag_all_yolox\add_new_6666\images" #负样本图片文件夹
save_path=r"F:\1213bag\bag_all_yolox\add_new_6666\labels" #生成空的txt文件夹
files = os.listdir(path)
print(files)
for pic in tqdm(files):
# # basename = os.path.basename(image_name)
before_name = os.path.splitext(pic)[0]
txt_name = os.path.splitext(before_name)[0] + ".txt"
txt_name = os.path.join(save_path,txt_name)
if os.path.exists(txt_name) == False:
f = open(txt_name, "w")
4.找出漏检样本
demo.py检测完,会有漏检生成空的txt,查找漏检图片放进另一个文件夹
# 导入os

本文总结了YOLOX在训练过程中遇到的问题及解决方案,包括无法指定GPU、类别错误、负样本生成、漏检样本查找、训练验证划分以及模型的计算量和参数量计算。针对标签错误,注意处理空格导致的类别混乱;对于计算模型指标,理解FPS、GFLOPs和Params在评估模型性能中的作用。
最低0.47元/天 解锁文章
7070

被折叠的 条评论
为什么被折叠?



