Skip to content

Commit

Permalink
Update default image preprocessing (#1268)
Browse files Browse the repository at this point in the history
Change-Id: I79144cd8b1353a08b8232ee0372641abb6c6b55e
  • Loading branch information
frankfliu authored Oct 5, 2021
1 parent 34c02a2 commit b94f0da
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,20 @@ protected void configPreProcess(Map<String, ?> arguments) {
if (arguments.containsKey("flag")) {
flag = Image.Flag.valueOf(arguments.get("flag").toString());
}
if (getBooleanValue(arguments, "centerCrop", false)) {
addTransform(new CenterCrop());
}
if (getBooleanValue(arguments, "resize", false)) {
String resize = getStringValue(arguments, "resize", "false");
if ("true".equals(resize)) {
addTransform(new Resize(width, height));
} else if (!"false".equals(resize)) {
String[] tokens = resize.split("\\s*,\\s*");
if (tokens.length > 1) {
addTransform(
new Resize(Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1])));
} else {
addTransform(new Resize(Integer.parseInt(tokens[0])));
}
}
if (getBooleanValue(arguments, "centerCrop", false)) {
addTransform(new CenterCrop(width, height));
}
if (getBooleanValue(arguments, "toTensor", true)) {
addTransform(new ToTensor());
Expand Down

0 comments on commit b94f0da

Please sign in to comment.