|
|
@@ -8,7 +8,7 @@
|
|
|
#include "model_detector.h"
|
|
|
|
|
|
#define STB_IMAGE_RESIZE_IMPLEMENTATION
|
|
|
-#include "../stable-diffusion.cpp-src/thirdparty/stb_image_resize.h"
|
|
|
+#include "../build/stable-diffusion.cpp-src/thirdparty/stb_image_resize.h"
|
|
|
|
|
|
extern "C" {
|
|
|
#include "stable-diffusion.h"
|
|
|
@@ -951,7 +951,9 @@ public:
|
|
|
uint32_t upscaleFactor,
|
|
|
int nThreads,
|
|
|
bool offloadParamsToCpu,
|
|
|
- bool direct) {
|
|
|
+ bool direct,
|
|
|
+ StableDiffusionWrapper::ProgressCallback progressCallback,
|
|
|
+ void* userData) {
|
|
|
StableDiffusionWrapper::GeneratedImage result;
|
|
|
|
|
|
auto startTime = std::chrono::high_resolution_clock::now();
|
|
|
@@ -960,6 +962,11 @@ public:
|
|
|
LOG_DEBUG("Input: " + std::to_string(inputWidth) + "x" + std::to_string(inputHeight) + "x" + std::to_string(inputChannels));
|
|
|
LOG_DEBUG("Upscale factor: " + std::to_string(upscaleFactor));
|
|
|
|
|
|
+ // Report initial progress
|
|
|
+ if (progressCallback) {
|
|
|
+ progressCallback(0, 1, 0.0f, userData);
|
|
|
+ }
|
|
|
+
|
|
|
// Validate input
|
|
|
if (inputWidth <= 0 || inputHeight <= 0 || inputChannels <= 0) {
|
|
|
lastError = "Invalid input image dimensions";
|
|
|
@@ -979,6 +986,11 @@ public:
|
|
|
|
|
|
LOG_DEBUG("Output: " + std::to_string(outputWidth) + "x" + std::to_string(outputHeight) + "x" + std::to_string(inputChannels));
|
|
|
|
|
|
+ // Report progress after validation
|
|
|
+ if (progressCallback) {
|
|
|
+ progressCallback(0, 1, 0.1f, userData);
|
|
|
+ }
|
|
|
+
|
|
|
// Allocate output buffer
|
|
|
std::vector<uint8_t> resizedData(outputWidth * outputHeight * inputChannels);
|
|
|
|
|
|
@@ -1008,6 +1020,11 @@ public:
|
|
|
|
|
|
LOG_DEBUG("Bilinear resize completed successfully in " + std::to_string(duration.count()) + "ms");
|
|
|
|
|
|
+ // Report completion progress
|
|
|
+ if (progressCallback) {
|
|
|
+ progressCallback(1, 1, 1.0f, userData);
|
|
|
+ }
|
|
|
+
|
|
|
// Return resized image
|
|
|
result.width = outputWidth;
|
|
|
result.height = outputHeight;
|
|
|
@@ -1195,9 +1212,11 @@ StableDiffusionWrapper::GeneratedImage StableDiffusionWrapper::upscaleImage(
|
|
|
uint32_t upscaleFactor,
|
|
|
int nThreads,
|
|
|
bool offloadParamsToCpu,
|
|
|
- bool direct) {
|
|
|
+ bool direct,
|
|
|
+ ProgressCallback progressCallback,
|
|
|
+ void* userData) {
|
|
|
std::lock_guard<std::mutex> lock(wrapperMutex);
|
|
|
- return pImpl->upscaleImage(esrganPath, inputData, inputWidth, inputHeight, inputChannels, upscaleFactor, nThreads, offloadParamsToCpu, direct);
|
|
|
+ return pImpl->upscaleImage(esrganPath, inputData, inputWidth, inputHeight, inputChannels, upscaleFactor, nThreads, offloadParamsToCpu, direct, progressCallback, userData);
|
|
|
}
|
|
|
|
|
|
std::string StableDiffusionWrapper::getLastError() const {
|