Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion oslactionspotting/apis/evaluate/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ def label2vector(
else:
frame = framerate * (seconds + 60 * minutes)

label = EVENT_DICTIONARY[event]
# in case of a event not in EVENT_DICTIONARY move with the evaluation
# as label maybe None it wont evaluate for all classes
# but only the ones configured in the config model file
label = EVENT_DICTIONARY.get(event)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was failing if you set only limited classes to the dataset it tries to evaluate everything but the dictionary will contain only the limited list of classes.


value = 1
if "visibility" in annotation.keys():
Expand Down
3 changes: 2 additions & 1 deletion oslactionspotting/datasets/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ def annotation(self, annotation):
frame = self.framerate * (seconds + 60 * minutes)

cont = False

# Initializing label var in case the cont is False dont thrown an error
label = None
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, it would fail as cont = False the label will not be declared, causing the code to crash.

if event not in self.classes:
cont = True
else:
Expand Down
23 changes: 22 additions & 1 deletion oslactionspotting/models/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,27 @@ def build_model(cfg, verbose=True, default_args=None):
neck=cfg.model.neck,
runner=cfg.runner.type,
)

# Adding reset_backbone, reset_neck and freeze_backbone will allow
# in case of transfer learning domains
if getattr(cfg.model, "freeze_backbone", False):
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added freeze_backbone, freeze_neck and reset_head usefull features for transfer learning scenarios, not sure this is ok from the maintainers to add this feature but thought to do it just in case.

for p in model.model.backbone.parameters():
p.requires_grad = False
logging.info(f"[INFO] Backbone is freeze_backbone: and set requires_grad=False")

# 2. Freeze neck (optional)
if getattr(cfg.model, "freeze_neck", False):
for p in model.model.neck.parameters():
logging.info(f"[INFO] Neck is set to freeze_neck: and set requires_grad=False")
p.requires_grad = False

# 3. Reset head
if getattr(cfg.model, "reset_head", False):
for m in model.model.head.modules():
if hasattr(m, "reset_parameters"):
m.reset_parameters()
logging.info("[INFO] Hed is set to reset: reset_head: reset_parameters() was called")

elif cfg.model.type == "E2E":
model = E2EModel(
cfg,
Expand Down Expand Up @@ -97,4 +118,4 @@ def build_model(cfg, verbose=True, default_args=None):
logging.info(f"Total trainable parameters: {total_params:,}")
logging.info(f"Number of parameter groups: {len(parameters_per_layer)}")

return model
return model