From f9f8cf0be7e9ed8200792534aa919beb18dd06fd Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Thu, 22 Feb 2024 23:02:46 +0100 Subject: [PATCH] feat: only generate output when input image was changed --- .github/workflows/release-windows.yml | 4 +++- resources/python/live-painting/main.py | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml index f967b4ef7..1e7395259 100644 --- a/.github/workflows/release-windows.yml +++ b/.github/workflows/release-windows.yml @@ -8,7 +8,7 @@ on: jobs: release: - runs-on: windows-latest-l + runs-on: windows-latest if: ${{ !contains(github.event.head_commit.message, 'chore(release)') }} permissions: contents: write # to be able to publish a GitHub release @@ -18,6 +18,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + persist-credentials: false - name: Setup node uses: actions/setup-node@v4 diff --git a/resources/python/live-painting/main.py b/resources/python/live-painting/main.py index 4a7326822..ae64493a0 100644 --- a/resources/python/live-painting/main.py +++ b/resources/python/live-painting/main.py @@ -239,6 +239,9 @@ def main(pipe, input_image_path, output_image_path, shutdown_event): strength = 0.99 guidance_scale = None + # When was the input image last modified + last_modified_time = None + # Queue to hold parameters received from stdin params_queue = queue.Queue() @@ -257,10 +260,18 @@ def main(pipe, input_image_path, output_image_path, shutdown_event): seed = parameters.get("seed", seed) strength = parameters.get("strength", strength) guidance_scale = parameters.get("guidance_scale", guidance_scale) - print(f"Updated parameters {parameters}") except queue.Empty: pass # No new parameters, proceed with the existing ones + # Get the current modified time of the input image + current_modified_time = os.path.getmtime(input_image_path) + + if current_modified_time != last_modified_time: + last_modified_time = current_modified_time + else: + # Skip this iteration since the input image has not changed + continue + # Only generate an image if the prompt is not empty if prompt is not None and prompt.strip(): torch.manual_seed(seed)