304 image = Image.new("RGB", (width, height), color='black') 305 draw = ImageDraw.Draw(image) 306 307 # Generate a random color for the text 308 font_color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) 309 310 font = ImageFont.truetype(font_path, font_size) 311
304 image = Image.new("RGB", (width, height), color='black') 305 draw = ImageDraw.Draw(image) 306 307 # Generate a random color for the text 308 font_color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) 309 310 font = ImageFont.truetype(font_path, font_size) 311
304 image = Image.new("RGB", (width, height), color='black') 305 draw = ImageDraw.Draw(image) 306 307 # Generate a random color for the text 308 font_color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) 309 310 font = ImageFont.truetype(font_path, font_size) 311
458 459 if caption == "": 460 processed_images = [process_image(img, text) for img in image] 461 else: 462 assert len(caption) == batch_size, "Number of captions does not match number of images" 463 processed_images = [process_image(img, cap) for img, cap in zip(image, caption)] 464 processed_batch = torch.cat(processed_images, dim=0) 465
816 class ImageAndMaskPreview(SaveImage): 817 def __init__(self): 818 self.output_dir = folder_paths.get_temp_directory() 819 self.type = "temp" 820 self.prefix_append = "_temp_" + ''.join(random.choice("abcdefghijklmnopqrstupvxyz") for x in range(5)) 821 self.compress_level = 4 822 823 @classmethod
1185 class PreviewAnimation: 1186 def __init__(self): 1187 self.output_dir = folder_paths.get_temp_directory() 1188 self.type = "temp" 1189 self.prefix_append = "_temp_" + ''.join(random.choice("abcdefghijklmnopqrstupvxyz") for x in range(5)) 1190 self.compress_level = 1 1191 1192 methods = {"default": 4, "fastest": 0, "slowest": 6}
1626 config = json.load(file) 1627 api_key_from_config = config.get("sai_api_key") 1628 headers["authorization"] = api_key_from_config 1629 1630 response = requests.post( 1631 f"https://api.stability.ai/v2beta/stable-image/generate/sd3", 1632 headers=headers, 1633 files = files, 1634 data = data, 1635 ) 1636 1637 if response.status_code == 200: 1638 # Convert the response content to a PIL Image