-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/add pre postprocessing example #103
Feature/add pre postprocessing example #103
Conversation
r2i::ImageFormat::Id required_format) override { | ||
r2i::RuntimeError error; | ||
int width; | ||
int height; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialize variables
width = in_frame->GetWidth(); | ||
height = in_frame->GetHeight(); | ||
|
||
std::shared_ptr<float> processed_data = PreProcessImage(( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this indentation looks wrong
} | ||
|
||
private: | ||
int required_width, required_height; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one variable per line
|
||
this->required_width = required_width; | ||
this->required_height = required_height; | ||
this->required_format = required_format; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you create these class variables? looks like you only use them on validate and you can pass them easily as parameters of the function
required_height, 0, channels); | ||
|
||
for (int i = 0; i < scaled_size; i += channels) { | ||
/* RGB = (RGB - Mean)*StdDev */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RGB = (RGB - Mean) / StdDev ?
|
||
class Example: public r2i::IPreprocessing { | ||
public: | ||
Example () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why example? I already now this is an example we are on the examples directory, I suggest to use meaningful name
39fcdee
to
41d4568
Compare
height = in_frame->GetHeight(); | ||
|
||
std::shared_ptr<float> processed_data = PreProcessImage( | ||
reinterpret_cast<const unsigned char *>(in_frame->GetData()), width, height, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a variable to hold the data as you did for width and height
this->scaled_ptr = std::shared_ptr<unsigned char>(new unsigned | ||
char[scaled_size], | ||
std::default_delete<const unsigned char[]>()); | ||
this->adjusted_ptr = std::shared_ptr<float>(new float[scaled_size], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are you storing scaled and adjusted images ptr on the class? I think you can use local variables
examples/r2i/onnxrt/inception.cc
Outdated
stbir_resize_uint8(input, width, height, 0, scaled.get(), reqwidth, | ||
reqheight, 0, channels); | ||
std::shared_ptr<r2i::IFrame> LoadImage(const std::string &path, int reqwidth, | ||
int reqheight, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variables name req_width and req_height for consistency
|
||
class TopSortPostprocessing: public r2i::IPostprocessing { | ||
public: | ||
std::shared_ptr<r2i::IPrediction> Apply(std::shared_ptr<r2i::IPrediction> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Pre/Post implementations should be moved to r2i, they shouldn't be in examples
- Pre/Post implementations should have tests
r2i/ipostprocessing.h
Outdated
@@ -32,7 +33,8 @@ class IPostprocessing { | |||
* \param prediction returned from the model inference. | |||
* \return Error with a description message. | |||
*/ | |||
virtual RuntimeError Apply(IPrediction &prediction) = 0; | |||
virtual std::shared_ptr<r2i::IPrediction> Apply( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This interface will change with my latest PR.
|
||
error = preprocessing->Apply(in_frame, out_frame); | ||
LONGS_EQUAL(r2i::RuntimeError::Code::NULL_PARAMETER, error.GetCode()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are other missing tests:
- Invalid format?
- Zero stddev?
- Output height != input height
- Output width != input width
- Output format != output format
- Input type not uchar
- Output type not float
7416e1e
to
0d56830
Compare
f91f609
to
7de8d7a
Compare
Included the following tests: *Zero standard deviation *Invalid input format id
7de8d7a
to
0bf3c84
Compare
No description provided.