419 420 421 def reduce_opacity(img, opacity): 422 """Returns an image with reduced opacity.""" 423 assert opacity >= 0 and opacity <= 1 424 if img.mode != 'RGBA': 425 img = img.convert('RGBA') 426 else:
432 433 434 def random_hex_color(): 435 # Generate three random values for RGB 436 r = random.randint(0, 255) 437 g = random.randint(0, 255) 438 b = random.randint(0, 255) 439
433 434 def random_hex_color(): 435 # Generate three random values for RGB 436 r = random.randint(0, 255) 437 g = random.randint(0, 255) 438 b = random.randint(0, 255) 439 440 # Convert RGB to hex format
434 def random_hex_color(): 435 # Generate three random values for RGB 436 r = random.randint(0, 255) 437 g = random.randint(0, 255) 438 b = random.randint(0, 255) 439 440 # Convert RGB to hex format 441 hex_color = "#{:02x}{:02x}{:02x}".format(r, g, b)
444 445 446 def random_rgb(): 447 # Generate three random values for RGB 448 r = random.randint(0, 255) 449 g = random.randint(0, 255) 450 b = random.randint(0, 255) 451
445 446 def random_rgb(): 447 # Generate three random values for RGB 448 r = random.randint(0, 255) 449 g = random.randint(0, 255) 450 b = random.randint(0, 255) 451 452 # Format RGB as a string in the format "128,128,128"
446 def random_rgb(): 447 # Generate three random values for RGB 448 r = random.randint(0, 255) 449 g = random.randint(0, 255) 450 b = random.randint(0, 255) 451 452 # Format RGB as a string in the format "128,128,128" 453 rgb_string = "{},{},{}".format(r, g, b)
137 # Draw grid based on the binary pattern 138 for row_index, row in enumerate(grid): 139 for col_index, bit in enumerate(row): 140 if jitter_distance != 0: 141 x_jitter = random.uniform(0, jitter_distance) 142 y_jitter = random.uniform(0, jitter_distance) 143 x1 = col_index * square_width + x_jitter 144 y1 = row_index * square_height + y_jitter
138 for row_index, row in enumerate(grid): 139 for col_index, bit in enumerate(row): 140 if jitter_distance != 0: 141 x_jitter = random.uniform(0, jitter_distance) 142 y_jitter = random.uniform(0, jitter_distance) 143 x1 = col_index * square_width + x_jitter 144 y1 = row_index * square_height + y_jitter 145 x2 = x1 + square_width + x_jitter
148 # Draw black square if bit is 1, else draw white square 149 #color = color1 if bit == 1 else color0 150 151 # Adjust color based on bias 152 if random.uniform(0, 1) < abs(bias): 153 color = color1 154 else: 155 color = color0
448 ] 449 450 for row in range(num_rows): 451 for col in range(num_cols): 452 shape_function = random.choice(shape_functions) 453 color = random.choice([color1, color2]) 454 size = random.uniform(20, min(width, height) / 2) 455 aspect_ratio = random.uniform(0.5, 2.0) # For shapes that use aspect ratio
449 450 for row in range(num_rows): 451 for col in range(num_cols): 452 shape_function = random.choice(shape_functions) 453 color = random.choice([color1, color2]) 454 size = random.uniform(20, min(width, height) / 2) 455 aspect_ratio = random.uniform(0.5, 2.0) # For shapes that use aspect ratio 456
450 for row in range(num_rows): 451 for col in range(num_cols): 452 shape_function = random.choice(shape_functions) 453 color = random.choice([color1, color2]) 454 size = random.uniform(20, min(width, height) / 2) 455 aspect_ratio = random.uniform(0.5, 2.0) # For shapes that use aspect ratio 456 457 center_x = col * (width / num_cols) + (width / num_cols) / 2
451 for col in range(num_cols): 452 shape_function = random.choice(shape_functions) 453 color = random.choice([color1, color2]) 454 size = random.uniform(20, min(width, height) / 2) 455 aspect_ratio = random.uniform(0.5, 2.0) # For shapes that use aspect ratio 456 457 center_x = col * (width / num_cols) + (width / num_cols) / 2 458 center_y = row * (height / num_rows) + (height / num_rows) / 2
216 else: 217 CR_RandomWeightLoRA.StridesMap[id_hash] = 0 218 219 last_weight = CR_RandomWeightLoRA.LastWeightMap.get(id_hash, None) 220 weight = uniform(weight_min, weight_max) 221 222 if last_weight is not None: 223 while weight == last_weight:
220 weight = uniform(weight_min, weight_max) 221 222 if last_weight is not None: 223 while weight == last_weight: 224 weight = uniform(weight_min, weight_max) 225 226 CR_RandomWeightLoRA.LastWeightMap[id_hash] = weight 227
355 356 def perform_randomization() -> set: 357 _lora_set = set() 358 359 rand_1 = random() 360 rand_2 = random() 361 rand_3 = random() 362
356 def perform_randomization() -> set: 357 _lora_set = set() 358 359 rand_1 = random() 360 rand_2 = random() 361 rand_3 = random() 362 363 apply_1 = True if (rand_1 <= chance_1 and switch_1 == "On") else False
357 _lora_set = set() 358 359 rand_1 = random() 360 rand_2 = random() 361 rand_3 = random() 362 363 apply_1 = True if (rand_1 <= chance_1 and switch_1 == "On") else False 364 apply_2 = True if (rand_2 <= chance_2 and switch_2 == "On") else False
127 choice_str = custom_values 128 else: 129 pass 130 131 multiline_text = '\n'.join([prepend_text + ''.join(random.choice(choice_str) for _ in range(string_length)) for _ in range(rows)]) 132 133 return (multiline_text, show_help, ) 134
165 if value_type == "hex color": 166 choice_str = '0123456789ABCDEF' 167 168 if value_type == "hex color": 169 multiline_text = '\n'.join(['#' + ''.join(random.choice(choice_str) for _ in range(6)) for _ in range(rows)]) 170 elif value_type == "rgb": 171 multiline_text = '\n'.join([f'{random.randint(0, 255)},{random.randint(0, 255)},{random.randint(0, 255)}' for _ in range(rows)]) 172 elif value_type == "matplotlib xkcd":
167 168 if value_type == "hex color": 169 multiline_text = '\n'.join(['#' + ''.join(random.choice(choice_str) for _ in range(6)) for _ in range(rows)]) 170 elif value_type == "rgb": 171 multiline_text = '\n'.join([f'{random.randint(0, 255)},{random.randint(0, 255)},{random.randint(0, 255)}' for _ in range(rows)]) 172 elif value_type == "matplotlib xkcd": 173 multiline_text = '\n'.join([random.choice(list(xkcd_colors.keys())).replace('xkcd:', '') for _ in range(rows)]) 174 else:
167 168 if value_type == "hex color": 169 multiline_text = '\n'.join(['#' + ''.join(random.choice(choice_str) for _ in range(6)) for _ in range(rows)]) 170 elif value_type == "rgb": 171 multiline_text = '\n'.join([f'{random.randint(0, 255)},{random.randint(0, 255)},{random.randint(0, 255)}' for _ in range(rows)]) 172 elif value_type == "matplotlib xkcd": 173 multiline_text = '\n'.join([random.choice(list(xkcd_colors.keys())).replace('xkcd:', '') for _ in range(rows)]) 174 else:
167 168 if value_type == "hex color": 169 multiline_text = '\n'.join(['#' + ''.join(random.choice(choice_str) for _ in range(6)) for _ in range(rows)]) 170 elif value_type == "rgb": 171 multiline_text = '\n'.join([f'{random.randint(0, 255)},{random.randint(0, 255)},{random.randint(0, 255)}' for _ in range(rows)]) 172 elif value_type == "matplotlib xkcd": 173 multiline_text = '\n'.join([random.choice(list(xkcd_colors.keys())).replace('xkcd:', '') for _ in range(rows)]) 174 else:
169 multiline_text = '\n'.join(['#' + ''.join(random.choice(choice_str) for _ in range(6)) for _ in range(rows)]) 170 elif value_type == "rgb": 171 multiline_text = '\n'.join([f'{random.randint(0, 255)},{random.randint(0, 255)},{random.randint(0, 255)}' for _ in range(rows)]) 172 elif value_type == "matplotlib xkcd": 173 multiline_text = '\n'.join([random.choice(list(xkcd_colors.keys())).replace('xkcd:', '') for _ in range(rows)]) 174 else: 175 pass 176
201 202 # Set the seed 203 random.seed(seed) 204 205 start_letter = random.choice('HV') 206 value_range = random.choice(values) 207 208 codes = []
202 # Set the seed 203 random.seed(seed) 204 205 start_letter = random.choice('HV') 206 value_range = random.choice(values) 207 208 codes = [] 209 for _ in range(rows):
207 208 codes = [] 209 for _ in range(rows): 210 # Generate a random number within the specified range 211 number = ''.join(random.choice(values) for _ in range(string_length)) 212 # Append the code to the list 213 codes.append(f"{start_letter}{number}") 214
245 for i in range(1, rows + 1): 246 print(temp) 247 if temp <= 99 - rows + i: 248 upper_bound = min(99, temp + (99 - temp) // (rows - i + 1)) 249 current_value = random.randint(temp, upper_bound) 250 multiline_text += f'{current_value}:{random.randint(0, 255)},{random.randint(0, 255)},{random.randint(0, 255)}\n' 251 252 temp = current_value + 1
246 print(temp) 247 if temp <= 99 - rows + i: 248 upper_bound = min(99, temp + (99 - temp) // (rows - i + 1)) 249 current_value = random.randint(temp, upper_bound) 250 multiline_text += f'{current_value}:{random.randint(0, 255)},{random.randint(0, 255)},{random.randint(0, 255)}\n' 251 252 temp = current_value + 1 253
246 print(temp) 247 if temp <= 99 - rows + i: 248 upper_bound = min(99, temp + (99 - temp) // (rows - i + 1)) 249 current_value = random.randint(temp, upper_bound) 250 multiline_text += f'{current_value}:{random.randint(0, 255)},{random.randint(0, 255)},{random.randint(0, 255)}\n' 251 252 temp = current_value + 1 253
246 print(temp) 247 if temp <= 99 - rows + i: 248 upper_bound = min(99, temp + (99 - temp) // (rows - i + 1)) 249 current_value = random.randint(temp, upper_bound) 250 multiline_text += f'{current_value}:{random.randint(0, 255)},{random.randint(0, 255)},{random.randint(0, 255)}\n' 251 252 temp = current_value + 1 253