-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2024-08-31 nightly release (db60022)
- Loading branch information
pytorchbot
committed
Aug 31, 2024
1 parent
65bc4d6
commit 2178693
Showing
27 changed files
with
394 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+4.61 KB
test/assets/fakedata/logos/rgb_pytorch_incorrectly_encoded_but_who_cares.heic
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
#include "common.h" | ||
#include <torch/torch.h> | ||
|
||
namespace vision { | ||
namespace image { | ||
|
||
void validate_encoded_data(const torch::Tensor& encoded_data) { | ||
TORCH_CHECK(encoded_data.is_contiguous(), "Input tensor must be contiguous."); | ||
TORCH_CHECK( | ||
encoded_data.dtype() == torch::kU8, | ||
"Input tensor must have uint8 data type, got ", | ||
encoded_data.dtype()); | ||
TORCH_CHECK( | ||
encoded_data.dim() == 1 && encoded_data.numel() > 0, | ||
"Input tensor must be 1-dimensional and non-empty, got ", | ||
encoded_data.dim(), | ||
" dims and ", | ||
encoded_data.numel(), | ||
" numels."); | ||
} | ||
|
||
bool should_this_return_rgb_or_rgba_let_me_know_in_the_comments_down_below_guys_see_you_in_the_next_video( | ||
ImageReadMode mode, | ||
bool has_alpha) { | ||
// Return true if the calling decoding function should return a 3D RGB tensor, | ||
// and false if it should return a 4D RGBA tensor. | ||
// This function ignores the requested "grayscale" modes and treats it as | ||
// "unchanged", so it should only used on decoders who don't support grayscale | ||
// outputs. | ||
|
||
if (mode == IMAGE_READ_MODE_RGB) { | ||
return true; | ||
} | ||
if (mode == IMAGE_READ_MODE_RGB_ALPHA) { | ||
return false; | ||
} | ||
// From here we assume mode is "unchanged", even for grayscale ones. | ||
return !has_alpha; | ||
} | ||
|
||
} // namespace image | ||
} // namespace vision |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.