From 30f4aaaa24af5d2650e2a6e8300da55dfe279dc7 Mon Sep 17 00:00:00 2001 From: Johannes Stelzer Date: Thu, 12 Jan 2023 10:16:31 +0100 Subject: [PATCH] helper function moved --- gradio_ui.py | 22 +--------------------- latent_blending.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/gradio_ui.py b/gradio_ui.py index dcb5ed4..d320cf5 100644 --- a/gradio_ui.py +++ b/gradio_ui.py @@ -26,7 +26,7 @@ from PIL import Image import torch from movie_util import MovieSaver from typing import Callable, List, Optional, Union -from latent_blending import get_time, yml_save, LatentBlending, add_frames_linear_interp +from latent_blending import get_time, yml_save, LatentBlending, add_frames_linear_interp, compare_dicts from stable_diffusion_holder import StableDiffusionHolder torch.set_grad_enabled(False) import gradio as gr @@ -35,26 +35,6 @@ import copy #%% -def compare_dicts(a, b): - """ - Compares two dictionaries a and b and returns a dictionary c, with all - keys,values that have shared keys in a and b but same values in a and b. - The values of a and b are stacked together in the output. - Example: - a = {}; a['bobo'] = 4 - b = {}; b['bobo'] = 5 - c = dict_compare(a,b) - c = {"bobo",[4,5]} - """ - c = {} - for key in a.keys(): - if key in b.keys(): - val_a = a[key] - val_b = b[key] - if val_a != val_b: - c[key] = [val_a, val_b] - return c - class BlendingFrontend(): def __init__(self, sdh=None): if sdh is None: diff --git a/latent_blending.py b/latent_blending.py index 4d1eb8d..0958b8d 100644 --- a/latent_blending.py +++ b/latent_blending.py @@ -1113,6 +1113,25 @@ def get_time(resolution=None): raise ValueError("bad resolution provided: %s" %resolution) return t +def compare_dicts(a, b): + """ + Compares two dictionaries a and b and returns a dictionary c, with all + keys,values that have shared keys in a and b but same values in a and b. + The values of a and b are stacked together in the output. + Example: + a = {}; a['bobo'] = 4 + b = {}; b['bobo'] = 5 + c = dict_compare(a,b) + c = {"bobo",[4,5]} + """ + c = {} + for key in a.keys(): + if key in b.keys(): + val_a = a[key] + val_b = b[key] + if val_a != val_b: + c[key] = [val_a, val_b] + return c def yml_load(fp_yml, print_fields=False): """ @@ -1144,6 +1163,8 @@ if __name__ == "__main__": sdh = StableDiffusionHolder(fp_ckpt, fp_config, device) + xxx + #%% Next let's set up all parameters quality = 'medium'