Skip to content

Commit 6d38fde

Browse files
authored
Merge pull request #169 from agentmorris/top-level-init
Added package-level __init__.py file
2 parents 0b52b2d + 319e941 commit 6d38fde

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

megadetector/__init__.py

Whitespace-only changes.

megadetector/detection/pytorch_detector.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ def _clean_yolo_imports(verbose=False,aggressive_cleanup=False):
193193
"""
194194

195195
modules_to_delete = []
196+
196197
for module_name in sys.modules.keys():
198+
197199
module = sys.modules[module_name]
198200
if not hasattr(module,'__file__') or (module.__file__ is None):
199201
continue
@@ -204,21 +206,20 @@ def _clean_yolo_imports(verbose=False,aggressive_cleanup=False):
204206
continue
205207
tokens = module_file.split('/')
206208

207-
# For local path imports, a module filename we might want to unload
208-
# might look like:
209+
# For local path imports, a module filename that should be unloaded might
210+
# look like:
209211
#
210212
# c:/git/yolov9/models/common.py
211213
#
212-
# For pip imports, a module filename we might want to unload might
213-
# look like:
214+
# For pip imports, a module filename that should be unloaded might look like:
214215
#
215216
# c:/users/user/miniforge3/envs/megadetector/lib/site-packages/yolov9/utils/__init__.py
216217
first_token_to_check = len(tokens) - 4
217218
for i_token,token in enumerate(tokens):
218219
if i_token < first_token_to_check:
219220
continue
220221
# Don't remove anything based on the environment name, which
221-
# allows follows "envs" in the path
222+
# always follows "envs" in the path
222223
if (i_token > 1) and (tokens[i_token-1] == 'envs'):
223224
continue
224225
if ('yolov5' in token) or ('yolov9' in token) or ('ultralytics' in token):
@@ -231,7 +232,10 @@ def _clean_yolo_imports(verbose=False,aggressive_cleanup=False):
231232
print('Exception during module review: {}'.format(str(e)))
232233
pass
233234

235+
# ...for each module in the global namespace
236+
234237
for module_name in modules_to_delete:
238+
235239
if module_name in sys.modules.keys():
236240
if verbose:
237241
try:
@@ -242,6 +246,8 @@ def _clean_yolo_imports(verbose=False,aggressive_cleanup=False):
242246
pass
243247
del sys.modules[module_name]
244248

249+
# ...for each module we want to remove from the global namespace
250+
245251
paths_to_delete = []
246252

247253
for p in sys.path:

0 commit comments

Comments
 (0)