Skip to content

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

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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