MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / readMaskImage

Function readMaskImage

plugins/wasmedge_stablediffusion/sd_func.cpp:112–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112sd_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
130void upscalerModel(const char *UpscaleModelPath, uint32_t UpscaleRepeats,
131 int32_t NThreads, uint32_t BatchCount, sd_image_t *Results) {

Callers 1

bodyMethod · 0.85

Calls 5

substrMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected