Saving extra text data in a PNG image file
First and foremost, let’s use Stable Diffusion to generate an image for testing. Not like the code we used in previous chapters, this time, we are going to use a JSON object to store the generation parameters.
Load the model:
import torch from diffusers import StableDiffusionPipeline model_id = "stablediffusionapi/deliberate-v2" text2img_pipe = StableDiffusionPipeline.from_pretrained( Â Â Â Â model_id, Â Â Â Â torch_dtype = torch.float16 ) # Then, we define all the parameters that will be used to generate an # image in a JSON object: gen_meta = { Â Â Â Â "model_id": model_id, Â Â Â Â "prompt": "high resolution, Â Â Â Â Â Â Â Â a photograph of an astronaut riding a horse", Â Â Â Â "seed": 123, Â Â Â Â "inference_steps": 30, Â Â Â ...