我有一个在 Python 中运行的图像生成脚本。
我想说的是,如果选择了“蓝色皮肤”,那么名称中带有“蓝色”的所有其他特征都必须遵循。
这是我要应用规则的脚本,因为此时所有特征都是随机选择的,然后根据此处选择的特征生成图像:
TOTAL_IMAGES = 30
all_images = []
def create_new_image():
new_image = {}
new_image ["Background"] = random.choices(background, background_weights)[0]
new_image ["Skin"] = random.choices(smol_skins, smol_skins_weights)[0]
new_image ["Hoodie"] = random.choices(hoodie, hoodie_weights)[0]
new_image ["Eyes"] = random.choices(eyes, eyes_weights)[0]
new_image ["Lower Eyelids"] = random.choices(lower_eyelids, lower_eyelids_weights)[0]
new_image ["Upper Eyelids"] = random.choices(upper_eyelids, upper_eyelids_weights)[0]
new_image ["Mouth"] = random.choices(mouth, mouth_weights)[0]
new_image ["Left Hand Traits"] = random.choices(leftHand_traits, leftHand_traits_weights)[0]
new_image ["Right Hand Traits"] = random.choices(rightHand_traits, rightHand_traits_weights)[0]
new_image ["Right Flipper Overlay"] = random.choices(rightFlipper_overlay, rightFlipper_overlay_weights)[0]
new_image ["Right Flipper Hoodie Overlay"] = random.choices(rightFlipperHoodie_overlay, rightFlipperHoodie_overlay_weights)[0]
new_image ["Head Traits"] = random.choices(head_traits, head_traits_weights)[0]
new_image ["Eyebrows"] = random.choices(eyebrows, eyebrows_weights)[0]
new_image ["Shadow Overlay"] = random.choices(shadow_overlay, shadow_overlay_weights)[0]
if new_image in all_images:
return create_new_image
else:
return new_image
所以我想要实现的是,如果“皮肤”选择“蓝色皮肤”,那么我想为“脚蹼覆盖”选择“蓝色右脚蹼覆盖”,依此类推。
我尝试了许多 if 语句,但似乎没有一个能奏效。我的想法是这样的:
if new_image[smol_skins("Blue Skin"):
return new_image[rightFlipper_overlay("Blue Right Flipper Overlay")
我不确定我是否在正确的轨道上..
我希望同样的规则适用于“蓝色皮肤”应具备的所有特征。
我刚开始使用 Python,所以任何帮助将不胜感激!谢谢!