pulsatrix
Loading...
Searching...
No Matches
image_transforms.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include <vector>
8
11
12namespace pulsatrix {
13
26class ResizeTransform : public Transform {
27public:
28 ResizeTransform(int64_t target_height, int64_t target_width, DeviceBackend* backend)
29 : target_height_(target_height), target_width_(target_width), backend_(backend) {}
30
31 [[nodiscard]] Sample apply(Sample sample) const override;
32
33private:
34 int64_t target_height_;
35 int64_t target_width_;
36 DeviceBackend* backend_;
37};
38
45public:
46 CenterCropTransform(int64_t crop_height, int64_t crop_width, DeviceBackend* backend)
47 : crop_height_(crop_height), crop_width_(crop_width), backend_(backend) {}
48
49 [[nodiscard]] Sample apply(Sample sample) const override;
50
51private:
52 int64_t crop_height_;
53 int64_t crop_width_;
54 DeviceBackend* backend_;
55};
56
63public:
64 NormalizeTransform(std::vector<float> mean, std::vector<float> std) : mean_(std::move(mean)), std_(std::move(std)) {}
65
66 [[nodiscard]] Sample apply(Sample sample) const override;
67
68private:
69 std::vector<float> mean_;
70 std::vector<float> std_;
71};
72
75public:
76 [[nodiscard]] Sample apply(Sample sample) const override;
77};
78
79} // namespace pulsatrix
Crops the centered (crop_height, crop_width) region of the image.
Definition image_transforms.hpp:44
Sample apply(Sample sample) const override
Applies this transform to a sample.
CenterCropTransform(int64_t crop_height, int64_t crop_width, DeviceBackend *backend)
Definition image_transforms.hpp:46
Vendor-agnostic compute/memory backend. CPUBackend, CUDABackend (Phase 1.5), and HIPBackend (Phase 1....
Definition device_backend.hpp:219
Mirrors the image left-right. In-place, no backend needed (same shape).
Definition image_transforms.hpp:74
Sample apply(Sample sample) const override
Applies this transform to a sample.
Per-channel normalization: pixel = (pixel - mean[c]) / std[c]. In-place, no backend needed (same shap...
Definition image_transforms.hpp:62
NormalizeTransform(std::vector< float > mean, std::vector< float > std)
Definition image_transforms.hpp:64
Sample apply(Sample sample) const override
Applies this transform to a sample.
Every transform in this file operates on sample.fields[0], assumed to be an image Tensor of shape (1,...
Definition image_transforms.hpp:26
Sample apply(Sample sample) const override
Applies this transform to a sample.
ResizeTransform(int64_t target_height, int64_t target_width, DeviceBackend *backend)
Definition image_transforms.hpp:28
A single sample-level preprocessing step (normalize, augment, tokenize, ...).
Definition transform.hpp:20
Abstract interface isolating vendor-specific memory/compute operations from Tensor/ComputationGraph.
Definition acquisition_functions.hpp:16
One dataset sample: an ordered list of Tensor fields (e.g. {features, label} or {image,...
Definition dataset.hpp:19
Sample-level preprocessing abstraction – Transform, Compose, TransformDataset.