This commit is contained in:
kbjiang 2022-09-11 09:44:26 -05:00
Родитель b3530e41d2
Коммит b9aa00be47
4 изменённых файлов: 21 добавлений и 21 удалений

Просмотреть файл

@ -70,7 +70,7 @@ class AnnotationWidget(object):
)
if os.path.exists(self.anno_path):
print(f"Loading existing annotation from {self.anno_path}.")
with open(self.anno_path, "r") as f:
with open(self.anno_path, encoding='utf_8') as f:
for line in f.readlines()[1:]:
vec = line.strip().split("\t")
im_filename = vec[0]

Просмотреть файл

@ -132,7 +132,7 @@ class LoadVideo: # for inference
class LoadImagesAndLabels: # for training
def __init__(self, path, img_size=(1088, 608), augment=False, transforms=None):
with open(path, 'r') as file:
with open(path, encoding='utf_8') as file:
self.img_files = file.readlines()
self.img_files = [x.replace('\n', '') for x in self.img_files]
self.img_files = list(filter(lambda x: len(x) > 0, self.img_files))
@ -361,7 +361,7 @@ class JointDataset(LoadImagesAndLabels): # for training
self.num_classes = 1
for ds, path in paths.items():
with open(path, 'r') as file:
with open(path, encoding='utf_8') as file:
self.img_files[ds] = file.readlines()
self.img_files[ds] = [osp.join(root, x.strip()) for x in self.img_files[ds]]
self.img_files[ds] = list(filter(lambda x: len(x) > 0, self.img_files[ds]))
@ -472,7 +472,7 @@ class DetDataset(LoadImagesAndLabels): # for training
self.tid_num = OrderedDict()
self.tid_start_index = OrderedDict()
for ds, path in paths.items():
with open(path, 'r') as file:
with open(path, encoding='utf_8') as file:
self.img_files[ds] = file.readlines()
self.img_files[ds] = [osp.join(root, x.strip()) for x in self.img_files[ds]]
self.img_files[ds] = list(filter(lambda x: len(x) > 0, self.img_files[ds]))

Просмотреть файл

@ -66,7 +66,7 @@ def read_mot_results(filename, is_gt, is_ignore):
ignore_labels = {2, 7, 8, 12}
results_dict = dict()
if os.path.isfile(filename):
with open(filename, 'r') as f:
with open(filename, encoding='utf_8') as f:
for line in f.readlines():
linelist = line.split(',')
if len(linelist) < 7:

Просмотреть файл

@ -1,20 +1,20 @@
def parse_model_cfg(path):
"""Parses the yolo-v3 layer configuration file and returns module definitions"""
file = open(path, 'r')
lines = file.read().split('\n')
lines = [x for x in lines if x and not x.startswith('#')]
lines = [x.rstrip().lstrip() for x in lines] # get rid of fringe whitespaces
module_defs = []
for line in lines:
if line.startswith('['): # This marks the start of a new block
module_defs.append({})
module_defs[-1]['type'] = line[1:-1].rstrip()
if module_defs[-1]['type'] == 'convolutional':
module_defs[-1]['batch_normalize'] = 0
else:
key, value = line.split("=")
value = value.strip()
module_defs[-1][key.rstrip()] = value.strip()
with open(path, encoding='utf_8') as file:
lines = file.read().split('\n')
lines = [x for x in lines if x and not x.startswith('#')]
lines = [x.rstrip().lstrip() for x in lines] # get rid of fringe whitespaces
module_defs = []
for line in lines:
if line.startswith('['): # This marks the start of a new block
module_defs.append({})
module_defs[-1]['type'] = line[1:-1].rstrip()
if module_defs[-1]['type'] == 'convolutional':
module_defs[-1]['batch_normalize'] = 0
else:
key, value = line.split("=")
value = value.strip()
module_defs[-1][key.rstrip()] = value.strip()
return module_defs
@ -24,7 +24,7 @@ def parse_data_cfg(path):
options = dict()
options['gpus'] = '0'
options['num_workers'] = '10'
with open(path, 'r') as fp:
with open(path, encoding='utf_8') as fp:
lines = fp.readlines()
for line in lines:
line = line.strip()