Skip to content

remove unused imports and functions + replace print with logger calls #158

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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

SkalskiP
Copy link
Collaborator

Description

This pull request includes a series of changes primarily focused on replacing print statements with logger calls.

Copy link
Collaborator

@isaacrob-roboflow isaacrob-roboflow left a comment

Choose a reason for hiding this comment

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

couple notes, need to discuss the expanded_scales bug fix

Comment on lines +239 to +244
if square_resize_div_64:
logger.info(f"Building Roboflow {image_set} dataset with square resize at resolution {resolution}")
dataset = CocoDetection(img_folder, ann_file, transforms=make_coco_transforms_square_div_64(image_set, resolution, multi_scale=args.multi_scale, expanded_scales=args.expanded_scales))
else:
logger.info(f"Building Roboflow {image_set} dataset at resolution {resolution}")
dataset = CocoDetection(img_folder, ann_file, transforms=make_coco_transforms(image_set, resolution, multi_scale=args.multi_scale, expanded_scales=args.expanded_scales))
Copy link
Collaborator

Choose a reason for hiding this comment

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

there is a bug in the existing implementation that is stopping expanded_scales from getting propagated to the dataset when training on roboflow data. you can see it clearly here. this change fixes that bug, which will likely increase performance. however, it'll also slow down training a bit and increase memory usage a bit. not sure that's what we want. worth discussing

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@isaacrob-roboflow what's your suggestion here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Want to keep the bug for now but comment that it exists, and then run a proper ablation so we know if it's worth including?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@isaacrob-roboflow That would be great! I’d really like to get this PR merged soon, since it touches a lot of areas and keeps running into conflicts. Plus, I’d rather not merge it right before the release — it increases the risk that something might go wrong.

Would you like me to add a TODO comment on line 239?

TODO: There is a bug in the current implementation that prevents `expanded_scales` from being propagated to the dataset when training on Roboflow data.

Alternatively, we could create a GitHub issue to track the problem. To be honest, I’d prefer the second option.

Copy link
Collaborator

Choose a reason for hiding this comment

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

let's do both and tag the issue in the comment?

Comment on lines +83 to +86
# Check if batch size is divisible by gradient accumulation steps
if batch_size % args.grad_accum_steps != 0:
logger.error(f"Batch size ({batch_size}) must be divisible by gradient accumulation steps ({args.grad_accum_steps})")
raise ValueError(f"Batch size ({batch_size}) must be divisible by gradient accumulation steps ({args.grad_accum_steps})")
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should be able to handle this case but I am not sure it is being handled correctly right now. nothing fundamental stopping us

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@isaacrob-roboflow My PR didn’t change the behavior here — it just made it consistent with how the logger is used elsewhere. I’m happy to explore better approaches, but that’s outside the scope of this PR.

Comment on lines +1 to +5
# ------------------------------------------------------------------------
# RF-DETR
# Copyright (c) 2025 Roboflow. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
Copy link
Collaborator

Choose a reason for hiding this comment

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

this file was probably also copied over from LW-DETR .. even though they don't have a trademark in theirs, should we add it for them? (assuming we did copy it .. )

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@isaacrob-roboflow This wasn’t copied from LW-DETR — I created it myself. All the code here is either written by us or by open-source contributors.

# Conflicts:
#	rfdetr/deploy/export.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants