Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add finetune single_class_dataset #351

Merged
merged 1 commit into from
Sep 14, 2024

Conversation

yuedongli1
Copy link
Collaborator

@yuedongli1 yuedongli1 commented Sep 11, 2024

Thank you for your contribution to the MindYOLO repo.
Before submitting this PR, please make sure:

Motivation

(Write your motivation for proposed changes here.)

Test Plan

(How should this PR be tested? Do you require special setup to run the test or repro the fixed bug?)

Related Issues and PRs

(Is this PR part of a group of changes? Link the other relevant PRs and Issues here. Use https://help.github.com/en/articles/closing-issues-using-keywords for help on GitHub syntax)

@@ -5,18 +5,17 @@
start_num = 1

# 获取当前目录下所有的.txt文件
files = [f for f in os.listdir('images/train') if f.endswith(extension)]
files = [f for f in os.listdir('images/val') if f.endswith(extension)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥要换这个

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

只需要对验证集做改名和生成json文件,这里怕误导用户

@@ -82,4 +82,3 @@ def init_coco_format():
# 为每个分区保存JSON文件
with open(f"./annotations/instances_val2017.json", "w") as json_file:
json.dump(coco_format, json_file, indent=4)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

空行

@@ -43,7 +42,7 @@ def xml2txt(xml, labels, name_list, img_path):
fil_name = root.find('filename').text[:-4]
if not os.path.exists(labels): # 如果路径不存在则创建
os.mkdir(labels)
out = open(labels + './' + fil_name + '.txt', 'w+')
out = open(labels + '/' + fil_name + '.txt', 'w+')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以换成 os.path.join(path1, path2)的方式

zhanghuiyao
zhanghuiyao previously approved these changes Sep 11, 2024

for i, file in enumerate(files, start=start_num):
# 构造新的文件名,使用zfill填充前导零
new_filename = f"{i:06d}{extension}"

# 使用os.rename重命名文件
# 需根据自己的路径修改
os.chdir('D:/Desktop/mindspore/yolo_car_detection/bddua/bdd100k/images/train')
os.chdir('D:/Desktop/mindspore/yolo_car_detection/bddua/bdd100k/images/val')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个搞成入参吧,代码里硬编码不好

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改为相对路径,并在readme中说明应在数据集的根目录下使用

@yuedongli1 yuedongli1 merged commit 1868066 into mindspore-lab:master Sep 14, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inside-test 内部开发者提的issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants