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

Fix loading problem for some of darknet's models, i.e. assert end_point <= self.size #836

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions darkflow/utils/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,26 @@ def __init__(self, path):
return
else:
self.size = os.path.getsize(path)# save the path
major, minor, revision, seen = np.memmap(path,
major, minor, revision = np.memmap(path,
shape = (), mode = 'r', offset = 0,
dtype = '({})i4,'.format(4))
dtype = '({})i4,'.format(3))

self.offset = 12

if major * 10 + minor >= 2:
# Reading version >= 2
seen = np.memmap(path,
shape = (), mode = 'r', offset = 12,
dtype = '({})i8,'.format(1))
self.offset += 8
else:
# Reading version >= 2
seen = np.memmap(path,
shape = (), mode = 'r', offset = 12,
dtype = '({})i4,'.format(1))
self.offset += 4

self.transpose = major > 1000 or minor > 1000
self.offset = 16

def walk(self, size):
if self.eof: return None
Expand Down Expand Up @@ -149,4 +164,4 @@ def model_name(file_path):
num = int(file_name[-1])
return '-'.join(file_name[:-1])
if ext == 'weights':
return file_name
return file_name