Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
1db6907b
Unverified
Commit
1db6907b
authored
Aug 09, 2023
by
Nicolas Hug
Committed by
GitHub
Aug 09, 2023
Browse files
Use libjpeg-turbo for tests and builds (#7672)
Co-authored-by:
Philip Meier
<
github.pmeier@posteo.de
>
parent
641fdd9f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
15 deletions
+40
-15
.github/scripts/setup-env.sh
.github/scripts/setup-env.sh
+2
-1
.github/scripts/unittest.sh
.github/scripts/unittest.sh
+1
-0
packaging/pre_build_script.sh
packaging/pre_build_script.sh
+2
-2
packaging/torchvision/meta.yaml
packaging/torchvision/meta.yaml
+3
-3
test/smoke_test.py
test/smoke_test.py
+2
-0
torchvision/csrc/io/image/cpu/decode_jpeg.cpp
torchvision/csrc/io/image/cpu/decode_jpeg.cpp
+15
-0
torchvision/csrc/io/image/cpu/decode_jpeg.h
torchvision/csrc/io/image/cpu/decode_jpeg.h
+3
-0
torchvision/csrc/io/image/image.cpp
torchvision/csrc/io/image/image.cpp
+12
-9
No files found.
.github/scripts/setup-env.sh
View file @
1db6907b
...
@@ -40,9 +40,10 @@ conda create \
...
@@ -40,9 +40,10 @@ conda create \
--quiet
--yes
\
--quiet
--yes
\
python
=
"
${
PYTHON_VERSION
}
"
pip
\
python
=
"
${
PYTHON_VERSION
}
"
pip
\
ninja cmake
\
ninja cmake
\
libpng
jpeg
\
libpng
\
'ffmpeg<4.3'
'ffmpeg<4.3'
conda activate ci
conda activate ci
conda
install
--quiet
--yes
libjpeg-turbo
-c
pytorch
pip
install
--progress-bar
=
off
--upgrade
setuptools
pip
install
--progress-bar
=
off
--upgrade
setuptools
# See https://github.com/pytorch/vision/issues/6790
# See https://github.com/pytorch/vision/issues/6790
...
...
.github/scripts/unittest.sh
View file @
1db6907b
...
@@ -11,4 +11,5 @@ echo '::group::Install testing utilities'
...
@@ -11,4 +11,5 @@ echo '::group::Install testing utilities'
pip
install
--progress-bar
=
off pytest pytest-mock pytest-cov
pip
install
--progress-bar
=
off pytest pytest-mock pytest-cov
echo
'::endgroup::'
echo
'::endgroup::'
python
test
/smoke_test.py
pytest
--junit-xml
=
"
${
RUNNER_TEST_RESULTS_DIR
}
/test-results.xml"
-v
--durations
=
25
pytest
--junit-xml
=
"
${
RUNNER_TEST_RESULTS_DIR
}
/test-results.xml"
-v
--durations
=
25
packaging/pre_build_script.sh
View file @
1db6907b
...
@@ -13,8 +13,8 @@ fi
...
@@ -13,8 +13,8 @@ fi
if
[[
"
$(
uname
)
"
==
Darwin
||
"
$OSTYPE
"
==
"msys"
]]
;
then
if
[[
"
$(
uname
)
"
==
Darwin
||
"
$OSTYPE
"
==
"msys"
]]
;
then
# Install libpng from Anaconda (defaults)
# Install libpng from Anaconda (defaults)
conda
install
libpng
"jpeg<=9b"
-yq
conda
install
libpng
-yq
conda
install
-yq
ffmpeg
=
4.2
-c
pytorch
conda
install
-yq
ffmpeg
=
4.2
libjpeg-turbo
-c
pytorch
# Copy binaries to be included in the wheel distribution
# Copy binaries to be included in the wheel distribution
if
[[
"
$OSTYPE
"
==
"msys"
]]
;
then
if
[[
"
$OSTYPE
"
==
"msys"
]]
;
then
...
...
packaging/torchvision/meta.yaml
View file @
1db6907b
...
@@ -10,7 +10,7 @@ requirements:
...
@@ -10,7 +10,7 @@ requirements:
build
:
build
:
-
{{
compiler('c')
}}
# [win]
-
{{
compiler('c')
}}
# [win]
-
libpng
-
libpng
-
jpeg
-
lib
jpeg
-turbo
# NOTE: The only ffmpeg version that we build is actually 4.2
# NOTE: The only ffmpeg version that we build is actually 4.2
-
ffmpeg >=4.2
# [not win]
-
ffmpeg >=4.2
# [not win]
...
@@ -28,7 +28,7 @@ requirements:
...
@@ -28,7 +28,7 @@ requirements:
-
requests
-
requests
-
libpng
-
libpng
-
ffmpeg >=4.2
# [not win]
-
ffmpeg >=4.2
# [not win]
-
jpeg
-
lib
jpeg
-turbo
-
pillow >=5.3.0, !=8.3.*
-
pillow >=5.3.0, !=8.3.*
-
pytorch-mutex 1.0 {{ build_variant }}
# [not osx ]
-
pytorch-mutex 1.0 {{ build_variant }}
# [not osx ]
{{
environ.get('CONDA_PYTORCH_CONSTRAINT')
}}
{{
environ.get('CONDA_PYTORCH_CONSTRAINT')
}}
...
@@ -62,7 +62,7 @@ test:
...
@@ -62,7 +62,7 @@ test:
requires
:
requires
:
-
pytest
-
pytest
-
scipy
-
scipy
-
jpeg
-
lib
jpeg
-turbo
-
ca-certificates
-
ca-certificates
...
...
test/smoke_test.py
View file @
1db6907b
...
@@ -78,6 +78,8 @@ def smoke_test_torchvision_resnet50_classify(device: str = "cpu") -> None:
...
@@ -78,6 +78,8 @@ def smoke_test_torchvision_resnet50_classify(device: str = "cpu") -> None:
def
main
()
->
None
:
def
main
()
->
None
:
print
(
f
"torchvision:
{
torchvision
.
__version__
}
"
)
print
(
f
"torchvision:
{
torchvision
.
__version__
}
"
)
print
(
f
"torch.cuda.is_available:
{
torch
.
cuda
.
is_available
()
}
"
)
print
(
f
"torch.cuda.is_available:
{
torch
.
cuda
.
is_available
()
}
"
)
print
(
f
"
{
torch
.
ops
.
image
.
_jpeg_version
()
=
}
"
)
assert
torch
.
ops
.
image
.
_is_compiled_against_turbo
()
smoke_test_torchvision
()
smoke_test_torchvision
()
smoke_test_torchvision_read_decode
()
smoke_test_torchvision_read_decode
()
smoke_test_torchvision_resnet50_classify
()
smoke_test_torchvision_resnet50_classify
()
...
...
torchvision/csrc/io/image/cpu/decode_jpeg.cpp
View file @
1db6907b
...
@@ -152,8 +152,23 @@ torch::Tensor decode_jpeg(const torch::Tensor& data, ImageReadMode mode) {
...
@@ -152,8 +152,23 @@ torch::Tensor decode_jpeg(const torch::Tensor& data, ImageReadMode mode) {
jpeg_destroy_decompress
(
&
cinfo
);
jpeg_destroy_decompress
(
&
cinfo
);
return
tensor
.
permute
({
2
,
0
,
1
});
return
tensor
.
permute
({
2
,
0
,
1
});
}
}
#endif // #if !JPEG_FOUND
int64_t
_jpeg_version
()
{
#ifdef JPEG_FOUND
return
JPEG_LIB_VERSION
;
#else
return
-
1
;
#endif
}
bool
_is_compiled_against_turbo
()
{
#ifdef LIBJPEG_TURBO_VERSION
return
true
;
#else
return
false
;
#endif
#endif
}
}
// namespace image
}
// namespace image
}
// namespace vision
}
// namespace vision
torchvision/csrc/io/image/cpu/decode_jpeg.h
View file @
1db6907b
...
@@ -10,5 +10,8 @@ C10_EXPORT torch::Tensor decode_jpeg(
...
@@ -10,5 +10,8 @@ C10_EXPORT torch::Tensor decode_jpeg(
const
torch
::
Tensor
&
data
,
const
torch
::
Tensor
&
data
,
ImageReadMode
mode
=
IMAGE_READ_MODE_UNCHANGED
);
ImageReadMode
mode
=
IMAGE_READ_MODE_UNCHANGED
);
C10_EXPORT
int64_t
_jpeg_version
();
C10_EXPORT
bool
_is_compiled_against_turbo
();
}
// namespace image
}
// namespace image
}
// namespace vision
}
// namespace vision
torchvision/csrc/io/image/image.cpp
View file @
1db6907b
...
@@ -19,15 +19,18 @@ PyMODINIT_FUNC PyInit_image(void) {
...
@@ -19,15 +19,18 @@ PyMODINIT_FUNC PyInit_image(void) {
namespace
vision
{
namespace
vision
{
namespace
image
{
namespace
image
{
static
auto
registry
=
torch
::
RegisterOperators
()
static
auto
registry
=
.
op
(
"image::decode_png"
,
&
decode_png
)
torch
::
RegisterOperators
()
.
op
(
"image::encode_png"
,
&
encode_png
)
.
op
(
"image::decode_png"
,
&
decode_png
)
.
op
(
"image::decode_jpeg"
,
&
decode_jpeg
)
.
op
(
"image::encode_png"
,
&
encode_png
)
.
op
(
"image::encode_jpeg"
,
&
encode_jpeg
)
.
op
(
"image::decode_jpeg"
,
&
decode_jpeg
)
.
op
(
"image::read_file"
,
&
read_file
)
.
op
(
"image::encode_jpeg"
,
&
encode_jpeg
)
.
op
(
"image::write_file"
,
&
write_file
)
.
op
(
"image::read_file"
,
&
read_file
)
.
op
(
"image::decode_image"
,
&
decode_image
)
.
op
(
"image::write_file"
,
&
write_file
)
.
op
(
"image::decode_jpeg_cuda"
,
&
decode_jpeg_cuda
);
.
op
(
"image::decode_image"
,
&
decode_image
)
.
op
(
"image::decode_jpeg_cuda"
,
&
decode_jpeg_cuda
)
.
op
(
"image::_jpeg_version"
,
&
_jpeg_version
)
.
op
(
"image::_is_compiled_against_turbo"
,
&
_is_compiled_against_turbo
);
}
// namespace image
}
// namespace image
}
// namespace vision
}
// namespace vision
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment