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

Misc lint fixes #1020

Merged
merged 1 commit into from
Jun 14, 2019
Merged
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
2 changes: 1 addition & 1 deletion references/detection/coco_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def convert_to_coco_api(ds):


def get_coco_api_from_dataset(dataset):
for i in range(10):
for _ in range(10):
if isinstance(dataset, torchvision.datasets.CocoDetection):
break
if isinstance(dataset, torch.utils.data.Subset):
Expand Down
2 changes: 1 addition & 1 deletion references/detection/group_by_aspect_ratio.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def __len__(self):
collate_fn=lambda x: x[0])
aspect_ratios = []
with tqdm(total=len(dataset)) as pbar:
for i, (img, _) in enumerate(data_loader):
for _i, (img, _) in enumerate(data_loader):
pbar.update(1)
height, width = img.shape[-2:]
aspect_ratio = float(height) / float(width)
Copy link
Contributor

Choose a reason for hiding this comment

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

@fmassa Shouldn't aspect_ratio be width/height?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the important thing in here is for it to be consistent between all the implementations, and I don't think it will change anything in this particular case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, it just looks weid to understand because it is different from other definition.

Copy link
Member Author

Choose a reason for hiding this comment

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

which definition?

Copy link
Contributor

Choose a reason for hiding this comment

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

Something like this and this, and also aspect_ratio = w / h is commonly defined in other places like computer graphics. Anyway, it doesn't affect the behavior in your code.

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe we can change this definition here without breaking the rest of the code. I would be willing to merge a PR that do this change.

Copy link
Contributor

Choose a reason for hiding this comment

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

@fmassa Please take a look at #1194

Expand Down
2 changes: 0 additions & 2 deletions references/detection/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import torchvision.models.detection
import torchvision.models.detection.mask_rcnn

from torchvision import transforms

from coco_utils import get_coco, get_coco_kp

from group_by_aspect_ratio import GroupedBatchSampler, create_aspect_ratio_groups
Expand Down
4 changes: 3 additions & 1 deletion test/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def setUpClass(cls):
cls.dtype = torch.float64

def slow_roi_pooling(self, x, rois, pool_h, pool_w, spatial_scale=1,
device=torch.device('cpu'), dtype=torch.float64):
device=None, dtype=torch.float64):
if device is None:
device = torch.device("cpu")
c = x.size(1)
y = torch.zeros(rois.size(0), c, pool_h, pool_w, dtype=dtype, device=device)

Expand Down
4 changes: 2 additions & 2 deletions test/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def test_randomresized_params(self):
img = to_pil_image(img)
size = 100
epsilon = 0.05
for i in range(10):
for _ in range(10):
scale_min = round(random.random(), 2)
scale_range = (scale_min, scale_min + round(random.random(), 2))
aspect_min = max(round(random.random(), 2), epsilon)
Expand All @@ -153,7 +153,7 @@ def test_randomresized_params(self):
aspect_ratio_obtained == 1.0)

def test_randomperspective(self):
for i in range(10):
for _ in range(10):
height = random.randint(24, 32) * 2
width = random.randint(24, 32) * 2
img = torch.ones(3, height, width)
Expand Down