MCPcopy Create free account
hub / github.com/UbiquitousLearning/mllm / apply

Method apply

mllm/preprocessor/visual/ImageTransform.cpp:30–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28Resize::Resize(int target_h, int target_w) : size_hw_(std::make_pair(target_h, target_w)) {}
29
30Image Resize::apply(const Image& input) const {
31 Image src = input; // mutable copy
32 if (size_hw_.has_value()) {
33 // Explicit resize to (H, W)
34 const int new_h = size_hw_->first;
35 const int new_w = size_hw_->second;
36 return src.resize(new_w, new_h); // Image::resize expects (w, h)
37 }
38
39 // Shorter-side resize with aspect ratio preserved
40 MLLM_RT_ASSERT(size_shorter_.has_value());
41 const int target_shorter = *size_shorter_;
42 const int h = src.h();
43 const int w = src.w();
44
45 const int shorter = std::min(h, w);
46 const double scale = static_cast<double>(target_shorter) / static_cast<double>(shorter);
47 const int new_h = static_cast<int>(std::round(h * scale));
48 const int new_w = static_cast<int>(std::round(w * scale));
49 return src.resize(new_w, new_h);
50}
51
52// ========================= CenterCrop =========================
53CenterCrop::CenterCrop(int crop_size) : crop_h_(crop_size), crop_w_(crop_size) {}

Callers 15

__init__Method · 0.80
freeze_activationMethod · 0.80
enable_fake_quantMethod · 0.80
disable_fake_quantMethod · 0.80
convertMethod · 0.80
recompute_scale_zpMethod · 0.80
__init__Method · 0.80
freeze_activationMethod · 0.80
enable_fake_quantMethod · 0.80
disable_fake_quantMethod · 0.80

Calls 10

minFunction · 0.85
resizeMethod · 0.80
hMethod · 0.80
wMethod · 0.80
cropMethod · 0.80
tensorMethod · 0.80
has_valueMethod · 0.45
permuteMethod · 0.45
rankMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected