Spaces:
Running
on
T4
Running
on
T4
Update edit_app.py
Browse files- edit_app.py +4 -13
edit_app.py
CHANGED
@@ -3,7 +3,6 @@ from __future__ import annotations
|
|
3 |
import math
|
4 |
import random
|
5 |
import sys
|
6 |
-
from argparse import ArgumentParser
|
7 |
|
8 |
import einops
|
9 |
import gradio as gr
|
@@ -99,17 +98,9 @@ def load_model_from_config(config, ckpt, vae_ckpt=None, verbose=False):
|
|
99 |
|
100 |
|
101 |
def main():
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
parser.add_argument("--ckpt", default="instruct-pix2pix-00-22000.ckpt", type=str)
|
106 |
-
parser.add_argument("--vae-ckpt", default=None, type=str)
|
107 |
-
args = parser.parse_args()
|
108 |
-
|
109 |
-
args.ckpt = hf_hub_download(repo_id="diffusers/pix2pix-sd", filename="instruct-pix2pix-00-22000.ckpt")
|
110 |
-
|
111 |
-
config = OmegaConf.load(args.config)
|
112 |
-
model = load_model_from_config(config, args.ckpt, args.vae_ckpt)
|
113 |
model.eval().cuda()
|
114 |
model_wrap = K.external.CompVisDenoiser(model)
|
115 |
model_wrap_cfg = CFGDenoiser(model_wrap)
|
@@ -151,7 +142,7 @@ def main():
|
|
151 |
image_cfg_scale = round(random.uniform(1.2, 1.8), ndigits=2) if randomize_cfg else image_cfg_scale
|
152 |
|
153 |
width, height = input_image.size
|
154 |
-
factor =
|
155 |
factor = math.ceil(min(width, height) * factor / 64) * 64 / min(width, height)
|
156 |
width = int((width * factor) // 64) * 64
|
157 |
height = int((height * factor) // 64) * 64
|
|
|
3 |
import math
|
4 |
import random
|
5 |
import sys
|
|
|
6 |
|
7 |
import einops
|
8 |
import gradio as gr
|
|
|
98 |
|
99 |
|
100 |
def main():
|
101 |
+
ckpt = hf_hub_download(repo_id="timbrooks/instruct-pix2pix", filename="instruct-pix2pix-00-22000.ckpt")
|
102 |
+
config = OmegaConf.load("configs/generate.yaml")
|
103 |
+
model = load_model_from_config(config, ckpt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
model.eval().cuda()
|
105 |
model_wrap = K.external.CompVisDenoiser(model)
|
106 |
model_wrap_cfg = CFGDenoiser(model_wrap)
|
|
|
142 |
image_cfg_scale = round(random.uniform(1.2, 1.8), ndigits=2) if randomize_cfg else image_cfg_scale
|
143 |
|
144 |
width, height = input_image.size
|
145 |
+
factor = 512 / max(width, height)
|
146 |
factor = math.ceil(min(width, height) * factor / 64) * 64 / min(width, height)
|
147 |
width = int((width * factor) // 64) * 64
|
148 |
height = int((height * factor) // 64) * 64
|