(self, device)
| 610 | |
| 611 | class SegText2Image: |
| 612 | def __init__(self, device): |
| 613 | print(f"Initializing SegText2Image to {device}") |
| 614 | self.torch_dtype = torch.float16 if 'cuda' in device else torch.float32 |
| 615 | self.controlnet = ControlNetModel.from_pretrained("fusing/stable-diffusion-v1-5-controlnet-seg", |
| 616 | torch_dtype=self.torch_dtype) |
| 617 | self.pipe = StableDiffusionControlNetPipeline.from_pretrained( |
| 618 | "runwayml/stable-diffusion-v1-5", controlnet=self.controlnet, safety_checker=StableDiffusionSafetyChecker.from_pretrained('CompVis/stable-diffusion-safety-checker'), |
| 619 | torch_dtype=self.torch_dtype) |
| 620 | self.pipe.scheduler = UniPCMultistepScheduler.from_config(self.pipe.scheduler.config) |
| 621 | self.pipe.to(device) |
| 622 | self.seed = -1 |
| 623 | self.a_prompt = 'best quality, extremely detailed' |
| 624 | self.n_prompt = 'longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit,' \ |
| 625 | ' fewer digits, cropped, worst quality, low quality' |
| 626 | |
| 627 | @prompts(name="Generate Image Condition On Segmentations", |
| 628 | description="useful when you want to generate a new real image from both the user description and segmentations. " |
nothing calls this directly
no outgoing calls
no test coverage detected