(self, device)
| 669 | |
| 670 | class DepthText2Image: |
| 671 | def __init__(self, device): |
| 672 | print(f"Initializing DepthText2Image to {device}") |
| 673 | self.torch_dtype = torch.float16 if 'cuda' in device else torch.float32 |
| 674 | self.controlnet = ControlNetModel.from_pretrained( |
| 675 | "fusing/stable-diffusion-v1-5-controlnet-depth", torch_dtype=self.torch_dtype) |
| 676 | self.pipe = StableDiffusionControlNetPipeline.from_pretrained( |
| 677 | "runwayml/stable-diffusion-v1-5", controlnet=self.controlnet, safety_checker=StableDiffusionSafetyChecker.from_pretrained('CompVis/stable-diffusion-safety-checker'), |
| 678 | torch_dtype=self.torch_dtype) |
| 679 | self.pipe.scheduler = UniPCMultistepScheduler.from_config(self.pipe.scheduler.config) |
| 680 | self.pipe.to(device) |
| 681 | self.seed = -1 |
| 682 | self.a_prompt = 'best quality, extremely detailed' |
| 683 | self.n_prompt = 'longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit,' \ |
| 684 | ' fewer digits, cropped, worst quality, low quality' |
| 685 | |
| 686 | @prompts(name="Generate Image Condition On Depth", |
| 687 | description="useful when you want to generate a new real image from both the user description and depth image. " |
nothing calls this directly
no outgoing calls
no test coverage detected