| 110 | } |
| 111 | |
| 112 | sd_image_t readMaskImage(Span<uint8_t> MaskImage, int Width, int Height) { |
| 113 | uint8_t *MaskImageBuffer = NULL; |
| 114 | std::string MaskImagePath(MaskImage.begin(), MaskImage.end()); |
| 115 | int Channel = 0; |
| 116 | if (MaskImagePath.substr(0, 5) == "path:"sv) { |
| 117 | MaskImageBuffer = |
| 118 | stbi_load(MaskImagePath.substr(5).data(), &Width, &Height, &Channel, 3); |
| 119 | } else if (MaskImage.size() != 0) { |
| 120 | MaskImageBuffer = stbi_load_from_memory(MaskImage.data(), MaskImage.size(), |
| 121 | &Width, &Height, &Channel, 3); |
| 122 | } else { |
| 123 | std::vector<uint8_t> Arr(Width * Height, 255); |
| 124 | MaskImageBuffer = Arr.data(); |
| 125 | } |
| 126 | return {static_cast<uint32_t>(Width), static_cast<uint32_t>(Height), 1, |
| 127 | MaskImageBuffer}; |
| 128 | } |
| 129 | |
| 130 | void upscalerModel(const char *UpscaleModelPath, uint32_t UpscaleRepeats, |
| 131 | int32_t NThreads, uint32_t BatchCount, sd_image_t *Results) { |