Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Commit 8d0bb31

Browse files
zRzR
authored andcommitted
update readme
1 parent 064a374 commit 8d0bb31

21 files changed

+409
-1363
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313
**```注意```**
1414

15-
+ 1.如果你需要下载最新版本的代码,请克隆```dev```分支,最新的代码无法保证性能稳定。<br>
15+
+ 如果你需要下载仅有识别的代码,请克隆```only-detect```分支,最新的代码无法保证性能稳定。<br>
16+
+ 如果你正在寻找雷达小目标识别的代码,请前往[这里](https://github.com/zRzRzRzRzRzRzR/Mult-YOLO-alogorithm-of-RoboMaster-Radar-Detection-2023)
1617

1718
## 环境配置
1819

@@ -209,14 +210,12 @@ __数据集开源地址: 链接: https://pan.baidu.com/s/1ayRI1MMw40ae4kuFZCXK_Q
209210
+ 如果推理图像修改,工程中的anchor和图像大小也需要修改,anchor修改请执行```pre-processing_script/change_anchor.py```
210211

211212
## 总结
212-
213-
+ 该项目针对RMUC2023赛季,如果你有好的建议,欢迎给我留言哦。
214-
+ 如果你觉得项目对你有帮助,请给个star吧~
215-
+ 如果你有更好的建议,欢迎提出PR,或者直接联系我哦,大家一起学习!
213+
+ 该项目针对RMUC2023赛季,感谢大家,由于本人已经退役,本项目不在维护。
214+
+ 如果你对该项目有兴趣,可以联系我们团队。
216215
+ __感谢西浦GMaster战队在比赛期间标注数据的嵌入式组和机械组的战友,你们都为视觉组做出了一份重要的贡献!__
217216

218217
## 联系方式
219218

220219
+ 作者微信: zR_ZYX
221220
+ 作者邮箱: [email protected]
222-
+ 团队邮箱: [email protected]
221+
+ 团队邮箱: [email protected]

pre-processing_script/__init__.py

100644100755
File mode changed.

pre-processing_script/change_anchor.py

100644100755
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
'''
2-
使用前必看:
3-
1.本脚本将yolov7训练的聚类环节单独抽出,方便在更改训练和检测数据集大小时修改anchoer的数据,本脚本采用的是yolo自带的k-means聚类方法。
4-
2.具体参数如下:
5-
dataset: 数据的yaml路径
6-
n: 类簇的个数
7-
img_size: 训练过程中的图片尺寸(32的倍数)
8-
thr: anchor的长宽比阈值,将长宽比限制在此阈值之内
9-
gen: k - means算法最大迭代次数(不理解的可以去看k - means算法)
10-
verbose: 打印参数
11-
3.输出anchor后,需要将其修改至 data 文件夹下对应的训练cfg文件才能生效。
12-
'''
13-
import sys
14-
sys.path.append('./')
15-
import utils.autoanchor as autoAC
16-
17-
new_anchors = autoAC.kmean_anchors('../data/winmill/win_kpt.yaml', 9, 416, 5.0, 1000, True)
18-
print("生成的anchor如下:")
19-
print(new_anchors)
1+
'''
2+
使用前必看:
3+
1.本脚本将yolov7训练的聚类环节单独抽出,方便在更改训练和检测数据集大小时修改anchoer的数据,本脚本采用的是yolo自带的k-means聚类方法。
4+
2.具体参数如下:
5+
dataset: 数据的yaml路径
6+
n: 类簇的个数
7+
img_size: 训练过程中的图片尺寸(32的倍数)
8+
thr: anchor的长宽比阈值,将长宽比限制在此阈值之内
9+
gen: k - means算法最大迭代次数(不理解的可以去看k - means算法)
10+
verbose: 打印参数
11+
3.输出anchor后,需要将其修改至 data 文件夹下对应的训练cfg文件才能生效。
12+
'''
13+
import sys
14+
sys.path.append('./')
15+
import utils.autoanchor as autoAC
16+
17+
new_anchors = autoAC.kmean_anchors('/root/Yolov7_radar/data/armor-2.yaml', 24, 1280, 5.0, 1000, True)
18+
print("生成的anchor如下:")
19+
print(new_anchors)

pre-processing_script/change_json2yolo.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

pre-processing_script/change_label.py

Lines changed: 32 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,41 @@
22
使用前必看:
33
1. 如果你是按照READ.md文档的顺序标注的,那么正常你是用不到这个文件的。如果你是从其他开源站获得的数据,由于标签不对需要更改标签,那么你可以使用这
44
个脚本帮助修改。
5-
2.使用本脚本前请备份你的标注文件。
5+
2.使用本脚本前请备份你的标注文件。下面的样例是将以YOLO格式导出的LabelStudio数据集转换为西浦GMaster训练的数据集
66
'''
77
import os
88
import argparse
99

1010

11-
def change_label_name(path):
12-
total_txt = os.listdir(path)
13-
for file in total_txt:
14-
file_name = path + '/' + file
15-
file = open(file_name, 'r')
16-
lines = file.readlines()
17-
for index, line in enumerate(lines):
18-
t = lines[index] # 读取当前行的内容
19-
num = int(t[0:2])
20-
21-
# # 在这里修改你想txt操作的内容
22-
# if num > 7 and num < 10:
23-
# t = str(num - 1) + t[1:] # 改成2加字符第二位往后
24-
# lines[index] = t # 改写lines中的内容
25-
if num == 1:
26-
t = str(0) + t[1:] # 改成2加字符第二位往后
27-
lines[index] = t # 改写lines中的内容
28-
if num == 8:
29-
t = str(1) + t[1:] # 改成2加字符第二位往后
30-
lines[index] = t # 改写lines中的内容
31-
#
32-
# if num != 15: # 切片判断前两个字符
33-
# t = ''
34-
# lines[index] = t
35-
#
36-
# if num > 10: # 切片判断前两个字符
37-
# t = str(num - 1) + t[2:]
38-
# lines[index] = t
39-
40-
# if num !=1 and num!=8:
41-
# t = ''
42-
# lines[index] = t
43-
44-
file.close()
45-
t = "".join(lines)
46-
file = open(file_name, 'w')
47-
file.write(t)
48-
file.close()
49-
50-
51-
if __name__ == '__main__':
52-
parser = argparse.ArgumentParser()
53-
parser.add_argument('path_dir', type=str, default='', help='Location of path')
11+
def update_labels(folder_path):
12+
# 你的旧的和新的类别顺序
13+
old_order = ["B1", "B2", "B3", "B4", "B5", "BB", "BO", "BS", "R1", "R2", "R3", "R4", "R5", "RB", "RO", "RS"]
14+
new_order = ["B1", "B2", "B3", "B4", "B5", "BO", "BS", "R1", "R2", "R3", "R4", "R5", "RO", "RS", "BB", "RB"]
15+
16+
# 创建一个字典来映射旧的id到新的id
17+
id_mapping = {old_order.index(name): new_order.index(name) for name in old_order}
18+
19+
# 遍历标签文件
20+
for root, dirs, files in os.walk(folder_path):
21+
for file in files:
22+
if file.endswith(".txt"): # 假设标签文件是.txt格式
23+
with open(os.path.join(root, file), "r") as f:
24+
lines = f.readlines()
25+
26+
# 修改每一行的标签id
27+
for i in range(len(lines)):
28+
parts = lines[i].split(" ")
29+
parts[0] = str(id_mapping[int(parts[0])]) # 更新id
30+
lines[i] = " ".join(parts)
31+
32+
# 将修改后的行写回文件
33+
with open(os.path.join(root, file), "w") as f:
34+
f.writelines(lines)
35+
36+
37+
if __name__ == "__main__":
38+
parser = argparse.ArgumentParser(description="Update label files")
39+
parser.add_argument("folder_path", type=str, help="Path to the folder containing label files")
5440
args = parser.parse_args()
55-
change_label_name(args.path_dir)
56-
print("Finish change_label_id!")
41+
42+
update_labels(args.folder_path)

pre-processing_script/change_name.py

100644100755
Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
'''
2-
使用前必看:
3-
1. 本代码用来重新批量命名图片和标签。默认状态下是根据命名方式为四位数的文件进行命名,例如将9000.png更改为1.png。
4-
2. 如果你的原始图片不符合(1)中的命名方式,可以更改 file_list中的key参数进行修改。
5-
3. 本代码一次只能处理一个文件夹。
6-
'''
7-
8-
import os
9-
import re
10-
import sys
11-
import argparse
12-
13-
14-
@staticmethod
15-
def rename(path, start_id):
16-
file_list = sorted(os.listdir(path), key=lambda x: int(x[:-4])) # 在这里修改排序规则
17-
os.chdir(path)
18-
for fileName in file_list:
19-
pat = ".+\.(jpg|png|gif|py|txt)"
20-
pattern = re.findall(pat, fileName)
21-
os.rename(fileName, (str(start_id) + '.' + pattern[0]))
22-
start_id = start_id + 1
23-
os.chdir(os.getcwd())
24-
sys.stdin.flush()
25-
26-
27-
if __name__ == '__main__':
28-
parser = argparse.ArgumentParser()
29-
parser.add_argument('--path_dir', type=str, default='/media/zr/Data/RoboMaster_data/RMvideos/radar_record_2023/pic', help='Location of path')
30-
parser.add_argument('--start_id', type=int, default=6300, help='start sort with the id')
31-
args = parser.parse_args()
32-
rename(args.path_dir, args.start_id)
33-
print("Finish Rename!")
1+
'''
2+
使用前必看:
3+
1. 本代码用来重新批量命名图片和标签。默认状态下是根据命名方式为四位数的文件进行命名,例如将9000.png更改为1.png。
4+
2. 如果你的原始图片不符合(1)中的命名方式,可以更改 file_list中的key参数进行修改。
5+
3. 本代码一次只能处理一个文件夹。
6+
'''
7+
8+
import os
9+
import re
10+
import sys
11+
import argparse
12+
13+
14+
@staticmethod
15+
def rename(path, start_id):
16+
file_list = sorted(os.listdir(path), key=lambda x: int(x[:-4])) # 在这里修改排序规则
17+
os.chdir(path)
18+
for fileName in file_list:
19+
pat = ".+\.(jpg|png|gif|py|txt)"
20+
pattern = re.findall(pat, fileName)
21+
os.rename(fileName, (str(start_id) + '.' + pattern[0]))
22+
start_id = start_id + 1
23+
os.chdir(os.getcwd())
24+
sys.stdin.flush()
25+
26+
27+
if __name__ == '__main__':
28+
parser = argparse.ArgumentParser()
29+
parser.add_argument('path_dir', type=str, default='', help='Location of path')
30+
parser.add_argument('--start_id', type=int, default=1, help='start sort with the id')
31+
args = parser.parse_args()
32+
rename(args.path_dir, args.start_id)
33+
print("Finish Rename!")

pre-processing_script/change_point_order.py

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)