leejet / stable-diffusion.cpp

Stable Diffusion in pure C/C++
MIT License
2.9k stars 232 forks source link

export some api to free the image memory #234

Open chinshou opened 2 months ago

chinshou commented 2 months ago
            for (int i = 0; i < params.video_frames; i++) {
                if (results[i].data == NULL) {
                    continue;
                }
                std::string final_image_path = i > 0 ? dummy_name + "_" + std::to_string(i + 1) + ".png" : dummy_name + ".png";
                stbi_write_png(final_image_path.c_str(), results[i].width, results[i].height, results[i].channel,
                               results[i].data, 0, get_image_params(params, params.seed + i).c_str());
                printf("save result image to '%s'\n", final_image_path.c_str());
                free(results[i].data);
                results[i].data = NULL;
            }
            free(results);

it looks like library use standard c free function to free the memory of the image. But there is no api exported to free the image memory. For 3rd language such as pascal, it is not convenient to call standard C to free the resource.

FSSRepo commented 2 months ago

I understand, for now the project is a mishmash of things, it still doesn't have a specific format to follow, the latest refactorings have made the code very verbose and difficult to understand.