-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DIP] Split resize 4D into NCHW and NHWC (#405)
- Loading branch information
1 parent
416e156
commit 0b73eae
Showing
18 changed files
with
547 additions
and
132 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
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
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,58 @@ | ||
//====- resize4D.cpp - Example of buddy-opt tool =============================// | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file implements a 4D resize example with dip.resize_4d operation. | ||
// The dip.resize_4d operation will be compiled into an object file with the | ||
// buddy-opt tool. | ||
// This file will be linked with the object file to generate the executable | ||
// file. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
#include "buddy/DIP/imgcodecs/loadsave.h" | ||
#include <buddy/Core/Container.h> | ||
#include <buddy/DIP/ImgContainer.h> | ||
#include <buddy/DIP/DIP.h> | ||
#include <buddy/DIP/ImageContainer.h> | ||
#include <iostream> | ||
#include <math.h> | ||
|
||
using namespace std; | ||
|
||
void testImplementation(int argc, char *argv[]) { | ||
// Read as colar image. | ||
dip::Image<float, 4> inputBatch(argv[1], dip::DIP_RGB, true); | ||
|
||
// Note : Both values in output image dimensions and scaling ratios must be | ||
// positive numbers. | ||
MemRef<float, 4> output = dip::Resize4D_NCHW( | ||
&inputBatch, dip::INTERPOLATION_TYPE::BILINEAR_INTERPOLATION, | ||
{1, 3, 224, 224} /*{image_cols, image_rows}*/); | ||
|
||
// Define Img with the output of Resize4D. | ||
intptr_t outSizes[3] = {output.getSizes()[2], output.getSizes()[3], | ||
output.getSizes()[1]}; | ||
|
||
Img<float, 3> outputImageResize4D(output.getData(), outSizes); | ||
|
||
// dip::imwrite(argv[2], outputImageResize4D); | ||
|
||
return; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
testImplementation(argc, argv); | ||
return 0; | ||
} |
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
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
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.