This commit is contained in:
Glenn Jocher 2019-12-10 18:04:24 -08:00
parent 2201cb4023
commit bb1a87d77f
1 changed files with 10 additions and 3 deletions

View File

@ -1,10 +1,17 @@
import os
import numpy as np import numpy as np
def parse_model_cfg(path): def parse_model_cfg(path):
# Parses the yolo-v3 layer configuration file and returns module definitions # Parse the yolo *.cfg file and return module definitions path may be 'cfg/yolov3.cfg', 'yolov3.cfg', or 'yolov3'
file = open(path, 'r') if not path.endswith('.cfg'): # add .cfg suffix if omitted
lines = file.read().split('\n') path += '.cfg'
if not os.path.exists(path) and not path.startswith('cfg' + os.sep): # add cfg/ prefix if omitted
path = 'cfg' + os.sep + path
with open(path, 'r') as f:
lines = f.read().split('\n')
lines = [x for x in lines if x and not x.startswith('#')] 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 lines = [x.rstrip().lstrip() for x in lines] # get rid of fringe whitespaces
mdefs = [] # module definitions mdefs = [] # module definitions