(self, device)
| 740 | |
| 741 | class NormalText2Image: |
| 742 | def __init__(self, device): |
| 743 | print(f"Initializing NormalText2Image to {device}") |
| 744 | self.torch_dtype = torch.float16 if 'cuda' in device else torch.float32 |
| 745 | self.controlnet = ControlNetModel.from_pretrained( |
| 746 | "fusing/stable-diffusion-v1-5-controlnet-normal", torch_dtype=self.torch_dtype) |
| 747 | self.pipe = StableDiffusionControlNetPipeline.from_pretrained( |
| 748 | "runwayml/stable-diffusion-v1-5", controlnet=self.controlnet, safety_checker=StableDiffusionSafetyChecker.from_pretrained('CompVis/stable-diffusion-safety-checker'), |
| 749 | torch_dtype=self.torch_dtype) |
| 750 | self.pipe.scheduler = UniPCMultistepScheduler.from_config(self.pipe.scheduler.config) |
| 751 | self.pipe.to(device) |
| 752 | self.seed = -1 |
| 753 | self.a_prompt = 'best quality, extremely detailed' |
| 754 | self.n_prompt = 'longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit,' \ |
| 755 | ' fewer digits, cropped, worst quality, low quality' |
| 756 | |
| 757 | @prompts(name="Generate Image Condition On Normal Map", |
| 758 | description="useful when you want to generate a new real image from both the user description and normal map. " |
nothing calls this directly
no outgoing calls
no test coverage detected