From e37251c5951c9e17514b859422e71c9579b7c9d1 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Sat, 4 Feb 2023 20:02:01 +0300 Subject: [PATCH 1/3] change default to a value that makes sense --- scripts/postprocessing_pixelization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/postprocessing_pixelization.py b/scripts/postprocessing_pixelization.py index d654f57..b4b98ac 100644 --- a/scripts/postprocessing_pixelization.py +++ b/scripts/postprocessing_pixelization.py @@ -178,7 +178,7 @@ class ScriptPostprocessingUpscale(scripts_postprocessing.ScriptPostprocessing): upscale_after = gr.Checkbox(False, label="Keep resolution") with gr.Column(): - pixel_size = gr.Slider(minimum=1, maximum=16, step=1, label="Pixel size", value=1, elem_id="pixelization_pixel_size") + pixel_size = gr.Slider(minimum=1, maximum=16, step=1, label="Pixel size", value=4, elem_id="pixelization_pixel_size") return { "enable": enable, From 7338e1ea3f36134b1f62bcc8ef83ecb7bc7f6e9f Mon Sep 17 00:00:00 2001 From: missionfloyd Date: Sun, 2 Apr 2023 17:46:31 -0600 Subject: [PATCH 2/3] Download models with gdown --- README.md | 2 -- install.py | 3 +++ scripts/postprocessing_pixelization.py | 14 ++++---------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index d807af0..38fa576 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,6 @@ Download all three models from the table and place them into the `checkpoints` d | https://drive.google.com/file/d/17f2rKnZOpnO9ATwRXgqLz5u5AZsyDvq_/view?usp=sharing | alias_net.pth | | https://drive.google.com/file/d/1i_8xL3stbLWNF4kdQJ50ZhnRFhSDh3Az/view?usp=sharing | 160_net_G_A.pth | -License of Pixelization seems to prevent me from reuploading models anywhere and google drive makes it impossible to download them automatically. - # Credits * Original repo: https://github.com/WuZongWei6/Pixelization diff --git a/install.py b/install.py index ea603a2..c0ad52a 100644 --- a/install.py +++ b/install.py @@ -10,3 +10,6 @@ try: os.remove(os.path.join(path, "pixelization", "models", "__init__.py")) except OSError as e: pass + +if not launch.is_installed("gdown"): + launch.run_pip("install gdown", "requirements for stable-diffusion-webui-pixelization") diff --git a/scripts/postprocessing_pixelization.py b/scripts/postprocessing_pixelization.py index b4b98ac..461f5b9 100644 --- a/scripts/postprocessing_pixelization.py +++ b/scripts/postprocessing_pixelization.py @@ -12,6 +12,7 @@ import numpy as np from pixelization.models.networks import define_G import pixelization.models.c2pGen +import gdown pixelize_code = [ 233356.8125, -27387.5918, -32866.8008, 126575.0312, -181590.0156, @@ -104,21 +105,14 @@ class Model(torch.nn.Module): def load(self): os.makedirs(path_checkpoints, exist_ok=True) - missing = False - if not os.path.exists(path_pixelart_vgg19): - print(f"Missing {path_pixelart_vgg19} - download it from https://drive.google.com/uc?id=1VRYKQOsNlE1w1LXje3yTRU5THN2MGdMM") - missing = True + gdown.download("https://drive.google.com/uc?id=1VRYKQOsNlE1w1LXje3yTRU5THN2MGdMM", path_pixelart_vgg19) if not os.path.exists(path_160_net_G_A): - print(f"Missing {path_160_net_G_A} - download it from https://drive.google.com/uc?id=1i_8xL3stbLWNF4kdQJ50ZhnRFhSDh3Az") - missing = True + gdown.download("https://drive.google.com/uc?id=1i_8xL3stbLWNF4kdQJ50ZhnRFhSDh3Az", path_160_net_G_A) if not os.path.exists(path_alias_net): - print(f"Missing {path_alias_net} - download it from https://drive.google.com/uc?id=17f2rKnZOpnO9ATwRXgqLz5u5AZsyDvq_") - missing = True - - assert not missing, 'Missing checkpoints for pixelization - see console for doqwnload links.' + gdown.download("https://drive.google.com/uc?id=17f2rKnZOpnO9ATwRXgqLz5u5AZsyDvq_", path_alias_net) with torch.no_grad(): self.G_A_net = define_G(3, 3, 64, "c2pGen", "instance", False, "normal", 0.02, [0]) From 4e5b40e9a4483e790e81b1aecc44ddebff735f5a Mon Sep 17 00:00:00 2001 From: AUTOMATIC <-> Date: Sat, 30 Dec 2023 15:59:38 +0300 Subject: [PATCH 3/3] use InputAccordion from 1.6.0 --- scripts/postprocessing_pixelization.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/scripts/postprocessing_pixelization.py b/scripts/postprocessing_pixelization.py index b4b98ac..2fb0d99 100644 --- a/scripts/postprocessing_pixelization.py +++ b/scripts/postprocessing_pixelization.py @@ -1,6 +1,6 @@ import os -from modules import scripts_postprocessing, devices, scripts +from modules import scripts_postprocessing, devices, scripts, ui_components import gradio as gr from modules.ui_components import FormRow @@ -171,13 +171,9 @@ class ScriptPostprocessingUpscale(scripts_postprocessing.ScriptPostprocessing): model = None def ui(self): - with FormRow(): - with gr.Column(): - with FormRow(): - enable = gr.Checkbox(False, label="Enable pixelization") - upscale_after = gr.Checkbox(False, label="Keep resolution") - - with gr.Column(): + with ui_components.InputAccordion(False, label="Pixelize") as enable: + with gr.Row(): + upscale_after = gr.Checkbox(False, label="Keep resolution") pixel_size = gr.Slider(minimum=1, maximum=16, step=1, label="Pixel size", value=4, elem_id="pixelization_pixel_size") return {