MCPcopy Create free account
hub / github.com/chenfei-wu/TaskMatrix / __init__

Method __init__

visual_chatgpt.py:346–359  ·  view source on GitHub ↗
(self, device)

Source from the content-addressed store, hash-verified

344
345class 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."

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected