Skip to content

Commit

Permalink
Add image extension to compilation instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
andfoy committed Jun 11, 2020
1 parent 7b9ec24 commit f97a9f0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
22 changes: 22 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,28 @@ def get_extensions():
)
)

try:
include_dirs += [os.environ['LIBRARY_INC']]
except KeyError:
pass

try:
library_dirs = [os.environ['LIBRARY_LIB']]
except KeyError:
library_dirs = []

# Image reading extension
image_src_dir = os.path.join(this_dir, 'torchvision', 'csrc', 'cpu', 'image')
image_src = glob.glob(os.path.join(image_src_dir, "*.cpp"))
ext_modules.append(extension(
'torchvision.image',
image_src,
include_dirs=include_dirs + image_src_dir,
library_dirs=library_dirs,
define_macros=define_macros,
extra_compile_args=extra_compile_args
))

ffmpeg_exe = distutils.spawn.find_executable('ffmpeg')
has_ffmpeg = ffmpeg_exe is not None

Expand Down
4 changes: 2 additions & 2 deletions test/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def test_decode_png(self):
size = os.path.getsize(img_path)
img_lpng = decode_png(torch.from_file(img_path, dtype=torch.uint8, size=size))
self.assertEqual(img_lpng, img_pil)

self.assertEqual(decode_png(torch.empty()), torch.empty())
self.assertEqual(decode_png(torch.randint(3, 5, (300,))), torch.empty())


if __name__ == '__main__':
unittest.main()
1 change: 0 additions & 1 deletion torchvision/io/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ def read_png(path):
raise ValueError("Expected a non empty file.")
data = torch.from_file(path, dtype=torch.uint8, size=size)
return decode_png(data)

0 comments on commit f97a9f0

Please sign in to comment.