Skip to content

Commit

Permalink
one more change
Browse files Browse the repository at this point in the history
  • Loading branch information
wenbingl committed Oct 28, 2024
1 parent 1e5ef8a commit d2acaa8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions operators/vision/image_decoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ struct DecodeImage {
return {};
}

class JMemorySourceManager : public jpeg_source_mgr {
public:
class JMemorySourceManager : public jpeg_source_mgr {
public:
// Constructor
JMemorySourceManager(const uint8_t* encoded_image_data, const int64_t encoded_image_data_len) {
// Initialize source fields
Expand Down
13 changes: 10 additions & 3 deletions test/test_tools_add_pre_post_processing_to_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,16 @@ def test_pytorch_superresolution(self):
result_img = Image.open(io.BytesIO(result_bytes))
result = np.array(result_img.convert("RGB"))
expected = np.array(Image.open(expected_output_image_path).convert("RGB"))
mse = np.mean((expected - result) ** 2)
print(f"MSE:{mse}")
self.assertLess(mse, 1e-4)

# check all pixel values are close. allowing for 0.1% of pixels to differ by 2 at the most.
#
# we expect some variance from the floating point operations involved during Resize and conversion of the
# original image to/from YCbCr. the different instructions used on different hardware can cause diffs, such as
# whether avx512 is used or not. MacOS seems to be slightly worse though (max of 2)
diffs = np.absolute(expected.astype(np.int32) - result.astype(np.int32))
total = np.sum(diffs)
print(f"Max diff:{diffs.max()} Total diffs:{total}")
self.assertTrue(diffs.max() < 3 and total < (result.size / 1000))

def create_pipeline_and_run_for_tokenizer(self, tokenizer_impl, tokenizer_type,
tokenizer_parameters, output_model: Path):
Expand Down

0 comments on commit d2acaa8

Please sign in to comment.