Skip to content

Commit

Permalink
Merge pull request #37 from zydou/pytorch0.3
Browse files Browse the repository at this point in the history
Support for pytorch v0.3
  • Loading branch information
Cysu authored Dec 8, 2017
2 parents 5db4f6b + ff2e335 commit 3293ca7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions reid/utils/data/transforms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from __future__ import absolute_import

from torchvision.transforms import *
from PIL import Image
import random
import math


class RectScale(object):
Expand Down

5 comments on commit 3293ca7

@Rizhiy
Copy link

@Rizhiy Rizhiy commented on 3293ca7 Dec 11, 2017

Choose a reason for hiding this comment

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

How does this add support for Pytorch v0.3? Did you merge wrong commits?
AFAIK to support Pytorch v0.3, you need to remove keepdim argument from torch.sum(), but I'm not sure how that interacts with v0.2.

@zydou
Copy link
Contributor

@zydou zydou commented on 3293ca7 Dec 11, 2017

Choose a reason for hiding this comment

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

Hi, @Rizhiy
Running the code before this commit under pytorch0.3 will raise errors:

NameError: name 'Image' is not defined
NameError: name 'random' is not defined
NameError: name 'math' is not defined

After import these packages explicitly in open-reid/reid/utils/data/transforms.py, the code works again.

@zydou
Copy link
Contributor

@zydou zydou commented on 3293ca7 Dec 11, 2017

Choose a reason for hiding this comment

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

Hi, @Rizhiy
I checked the pytorch 0.3 docs and found that the keepdim argument is still remained in torch.sum(), torch.mean(), torch.max(), torch.min(), etc.
Please see here

@Rizhiy
Copy link

@Rizhiy Rizhiy commented on 3293ca7 Dec 11, 2017

Choose a reason for hiding this comment

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

Sorry, I'm an idiot. I think I have been using the old pytorch all this time since conda installs it by default.
My mistake.

@end7
Copy link

@end7 end7 commented on 3293ca7 Apr 26, 2020

Choose a reason for hiding this comment

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

Hello, the following problem appears in my code: My environment is pytorch0.4
Traceback (most recent call last):
File "F:/MyDownloads/open-reid-master/open-reid-master/examples/softmax_loss.py", line 217, in
main(parser.parse_args())
File "F:/MyDownloads/open-reid-master/open-reid-master/examples/softmax_loss.py", line 104, in main
metric = DistanceMetric(algorithm=args.dist_metric)
File "F:\MyDownloads\open-reid-master\open-reid-master\reid\dist_metric.py", line 13, in init
self.metric = get_metric(self.algorithm, *args, **kwargs)
File "F:\MyDownloads\open-reid-master\open-reid-master\reid\metric_learning_init_.py", line 25, in get_metric
return __factory[algorithm](*args, **kwargs)
TypeError: Can't instantiate abstract class Euclidean with abstract methods get_metric, score_pairs

Please sign in to comment.