Skip to content

How to properly cancel an image to image generation. #1652

@StudenteChamp2

Description

@StudenteChamp2

Found this with Google Agent. Is it safe?

`

	sd_set_progress_callback(ProgressCallback, &m_stopRender);
	sd_image_t* result = nullptr;
	try
	{
		result = generate_image(ctx, &sd_img_gen_params);
		_ASSERT(result && result[0].data);
	}
	catch (const std::runtime_error& e)
	{
		goto FreeMemory;
	}

`

Progress CB look like this:
void ProgressCallback(int step, int steps, float time, void* user_data) { if (*((bool*)user_data)) { throw std::runtime_error("Generation interrupted."); } }

FreeMemory free the context(sd_ctx_t* )and output image memory.

THANKS!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions