From dcb96084a5f827a9ffef88a91a246f90566a5cf1 Mon Sep 17 00:00:00 2001 From: bigcat88 Date: Tue, 23 Dec 2025 18:02:03 +0200 Subject: [PATCH] make the initial value of a random seed deterministic --- py/text_image.py | 4 +--- py/text_image_v2.py | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/py/text_image.py b/py/text_image.py index c31fc7f..79ea8b8 100644 --- a/py/text_image.py +++ b/py/text_image.py @@ -1,5 +1,4 @@ import torch -import time import random from PIL import Image, ImageFont, ImageDraw from .imagefunc import AnyType, log, tensor2pil, pil2tensor, image2mask, get_resource_dir, RGB2RGBA, random_numbers @@ -19,7 +18,6 @@ class TextImage: FONT_LIST = list(FONT_DICT.keys()) layout_list = ['horizontal', 'vertical'] - random_seed = int(time.time()) return { "required": { @@ -31,7 +29,7 @@ class TextImage: "vertical_border": ("FLOAT", {"default": 5, "min": -100, "max": 100, "step": 0.1}), # 上距离百分比 "scale": ("FLOAT", {"default": 80, "min": 0.1, "max": 999, "step": 0.01}), # 整体大小与画面长宽比,横排与宽比,竖排与高比 "variation_range": ("INT", {"default": 0, "min": 0, "max": 100, "step": 1}), # 随机大小和位置范围 - "variation_seed": ("INT", {"default": random_seed, "min": 0, "max": 999999999999, "step": 1}), # 随机种子 + "variation_seed": ("INT", {"default": 123, "min": 0, "max": 999999999999, "step": 1}), # 随机种子 "layout": (layout_list,), # 横排or竖排 "width": ("INT", {"default": 512, "min": 4, "max": 999999, "step": 1}), "height": ("INT", {"default": 512, "min": 4, "max": 999999, "step": 1}), diff --git a/py/text_image_v2.py b/py/text_image_v2.py index d6b0a45..3e81bd2 100644 --- a/py/text_image_v2.py +++ b/py/text_image_v2.py @@ -1,5 +1,4 @@ import torch -import time import random from PIL import Image, ImageFont, ImageDraw from .imagefunc import AnyType, log, tensor2pil, pil2tensor, image2mask, get_resource_dir, RGB2RGBA, random_numbers @@ -18,7 +17,6 @@ class TextImage_v2: FONT_LIST = list(FONT_DICT.keys()) layout_list = ['horizontal', 'vertical'] - random_seed = int(time.time()) return { "required": { "text": ("STRING", {"multiline": True, "default": "Text"}), @@ -29,7 +27,7 @@ class TextImage_v2: "vertical_border": ("FLOAT", {"default": 5, "min": -100, "max": 100, "step": 0.1}), # 上距离百分比 "scale": ("FLOAT", {"default": 80, "min": 0.1, "max": 999, "step": 0.01}), # 整体大小与画面长宽比,横排与宽比,竖排与高比 "variation_range": ("INT", {"default": 0, "min": 0, "max": 100, "step": 1}), # 随机大小和位置范围 - "variation_seed": ("INT", {"default": random_seed, "min": 0, "max": 999999999999, "step": 1}), # 随机种子 + "variation_seed": ("INT", {"default": 123, "min": 0, "max": 999999999999, "step": 1}), # 随机种子 "layout": (layout_list,), # 横排or竖排 "width": ("INT", {"default": 512, "min": 4, "max": 999999, "step": 1}), "height": ("INT", {"default": 512, "min": 4, "max": 999999, "step": 1}),