(self, device)
| 344 | |
| 345 | class CannyText2Image: |
| 346 | def __init__(self, device): |
| 347 | print(f"Initializing CannyText2Image to {device}") |
| 348 | self.torch_dtype = torch.float16 if 'cuda' in device else torch.float32 |
| 349 | self.controlnet = ControlNetModel.from_pretrained("fusing/stable-diffusion-v1-5-controlnet-canny", |
| 350 | torch_dtype=self.torch_dtype) |
| 351 | self.pipe = StableDiffusionControlNetPipeline.from_pretrained( |
| 352 | "runwayml/stable-diffusion-v1-5", controlnet=self.controlnet, safety_checker=StableDiffusionSafetyChecker.from_pretrained('CompVis/stable-diffusion-safety-checker'), |
| 353 | torch_dtype=self.torch_dtype) |
| 354 | self.pipe.scheduler = UniPCMultistepScheduler.from_config(self.pipe.scheduler.config) |
| 355 | self.pipe.to(device) |
| 356 | self.seed = -1 |
| 357 | self.a_prompt = 'best quality, extremely detailed' |
| 358 | self.n_prompt = 'longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, ' \ |
| 359 | 'fewer digits, cropped, worst quality, low quality' |
| 360 | |
| 361 | @prompts(name="Generate Image Condition On Canny Image", |
| 362 | description="useful when you want to generate a new real image from both the user description and a canny image." |
nothing calls this directly
no outgoing calls
no test coverage detected