my-sd/extensions-builtin/sd_forge_svd/scripts/forge_svd.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.2 KiB
Python
Raw Normal View History

2024-01-26 05:48:59 +00:00
import gradio as gr
2024-01-26 05:51:57 +00:00
import os
2024-01-26 05:48:59 +00:00
from modules import scripts, script_callbacks
2024-01-26 05:51:57 +00:00
from modules.paths import models_path
2024-01-26 05:54:40 +00:00
from modules import shared
2024-01-26 05:51:57 +00:00
svd_root = os.path.join(models_path, 'svd')
os.makedirs(svd_root, exist_ok=True)
2024-01-26 05:54:40 +00:00
svd_filenames = []
def update_svd_filenames():
global svd_filenames
svd_filenames = list(shared.walk_files(svd_root, allowed_extensions=[".pt", ".ckpt", ".safetensors"]))
return svd_filenames
2024-01-26 05:48:59 +00:00
class ForgeSVD(scripts.Script):
def __init__(self) -> None:
super().__init__()
def title(self):
return "SVD"
def show(self, is_img2img):
return scripts.AlwaysVisible
def ui(self, is_img2img):
return ()
def on_ui_tabs():
with gr.Blocks(analytics_enabled=False) as svd_block:
with gr.Row():
with gr.Column():
width = gr.Slider(label="width", minimum=64, maximum=2048, value=512, step=64, interactive=True)
height = gr.Slider(label="height", minimum=64, maximum=2048, value=512, step=64, interactive=True)
with gr.Column():
png_output = gr.Button(value="Save PNG")
return [(svd_block, "SVD", "svd")]
script_callbacks.on_ui_tabs(on_ui_tabs)