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

Minimally support accimage.Image #15

Closed
wants to merge 3 commits into from
Closed

Minimally support accimage.Image #15

wants to merge 3 commits into from

Conversation

Maratyszcza
Copy link
Contributor

Make torchvision use accimage.Image when available instead of PIL.Image in folder-based loader.

@soumith
Copy link
Member

soumith commented Dec 14, 2016

i'm going to request two small changes.

  1. allow a runtime override of accimage or IPLImage, maybe torchvision.image_backend = 'accimage' / 'IPLImage' (or something better if you propose)
  2. A real quick set of unit tests based on a test image. There should be one .eq function that simply does pixel-wise compare, and all supported functions can be cross-tested. For now the unit tests dont have to pass, we'll fix them rapidly over the next week.

if accimage is not None and isinstance(pic, accimage.Image):
nppic = np.empty([pic.channels, pic.height, pic.width])
pic.copyto(nppic)
img = torch.from_numpy(np.transpose(nppic, axes=(1, 2, 0)))

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

if accimage is None:
img = Image.open(os.path.join(self.root, path)).convert('RGB')
else:
img = accimage.Image(os.path.join(self.root, path))

This comment was marked as off-topic.

This comment was marked as off-topic.

@Maratyszcza
Copy link
Contributor Author

This code is merged, with @colesbury's modifications, as #153, so I close the PR.

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.

3 participants