-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_config.py
More file actions
59 lines (42 loc) · 1.21 KB
/
init_config.py
File metadata and controls
59 lines (42 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 5 10:55:29 2019
@author: SarachErudite
"""
import os
import csv
"""
Config Parameter
"""
# list class label sort by number
class_number = 1
class_label = ['raccoon']
classes_file = 'classes.names'
# list images to training set and test set
train_detail = 'train_list_images.txt'
valid_detail = 'test_list_images.txt'
# where to keep '.weights' files
weights_dir = 'weights'
"""
Process code
"""
# Create class detail file
with open(classes_file, 'a') as csvFile:
for name in class_label :
row = [name]
writer = csv.writer(csvFile, delimiter=' ')
writer.writerow(row)
csvFile.close()
current_path = os.getcwd()
train_path = os.path.join(current_path, train_detail)
test_path = os.path.join(current_path, valid_detail)
class_path = os.path.join(current_path, classes_file)
weights_path = os.path.join(current_path, weights_dir, '')
#Create darknet.data files
text = 'classes = ' + str(class_number) + '\n'
text += 'train = ' + train_path + '\n'
text += 'valid = ' + test_path + '\n'
text += 'names = ' + class_path + '\n'
text += 'backup = ' + weights_path + '\n'
with open("darknet.data", 'w') as text_file:
text_file.write(text)