Check out this demo here where you can draw and then use your drawing and a prompt to generate new images:
https://huggingface.co/spaces/huggingface/diffuse-the-rest
To understand how stable diffusion works, see:
https://www.paepper.com/blog/posts/how-and-why-stable-diffus...