BestWishYsh
commited on
Commit
•
3adb503
1
Parent(s):
32a13ae
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ from utils.unet import UNet3DConditionModel
|
|
15 |
from utils.pipeline_magictime import MagicTimePipeline
|
16 |
from utils.util import save_videos_grid, convert_ldm_unet_checkpoint, convert_ldm_clip_checkpoint, convert_ldm_vae_checkpoint, load_diffusers_lora_unet, convert_ldm_clip_text_model
|
17 |
|
18 |
-
pretrained_model_path = "
|
19 |
inference_config_path = "./sample_configs/RealisticVision.yaml"
|
20 |
magic_adapter_s_path = "./ckpts/Magic_Weights/magic_adapter_s/magic_adapter_s.ckpt"
|
21 |
magic_adapter_t_path = "./ckpts/Magic_Weights/magic_adapter_t"
|
@@ -63,7 +63,7 @@ os.system(f"rm -rf gradio_cached_examples/")
|
|
63 |
|
64 |
|
65 |
class MagicTimeController:
|
66 |
-
def __init__(self):
|
67 |
|
68 |
# config dirs
|
69 |
self.basedir = os.getcwd()
|
@@ -85,13 +85,18 @@ class MagicTimeController:
|
|
85 |
# config models
|
86 |
self.inference_config = OmegaConf.load(inference_config_path)[1]
|
87 |
|
88 |
-
self.tokenizer = CLIPTokenizer.from_pretrained(pretrained_model_path, subfolder="tokenizer")
|
89 |
-
self.text_encoder = CLIPTextModel.from_pretrained(pretrained_model_path, subfolder="text_encoder").
|
90 |
-
self.vae = AutoencoderKL.from_pretrained(pretrained_model_path, subfolder="vae").
|
91 |
-
self.unet = UNet3DConditionModel.from_pretrained_2d(pretrained_model_path, subfolder="unet", unet_additional_kwargs=OmegaConf.to_container(self.inference_config.unet_additional_kwargs)).
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
95 |
self.update_motion_module(self.motion_module_list[0])
|
96 |
self.update_dreambooth(self.dreambooth_list[0])
|
97 |
|
@@ -191,9 +196,14 @@ class MagicTimeController:
|
|
191 |
"dreambooth": dreambooth_dropdown,
|
192 |
}
|
193 |
return gr.Video(value=save_sample_path), gr.Json(value=json_config)
|
194 |
-
|
195 |
-
controller = MagicTimeController()
|
196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
|
198 |
def ui():
|
199 |
with gr.Blocks(css=css) as demo:
|
|
|
15 |
from utils.pipeline_magictime import MagicTimePipeline
|
16 |
from utils.util import save_videos_grid, convert_ldm_unet_checkpoint, convert_ldm_clip_checkpoint, convert_ldm_vae_checkpoint, load_diffusers_lora_unet, convert_ldm_clip_text_model
|
17 |
|
18 |
+
pretrained_model_path = "./ckpts/Base_Model/stable-diffusion-v1-5"
|
19 |
inference_config_path = "./sample_configs/RealisticVision.yaml"
|
20 |
magic_adapter_s_path = "./ckpts/Magic_Weights/magic_adapter_s/magic_adapter_s.ckpt"
|
21 |
magic_adapter_t_path = "./ckpts/Magic_Weights/magic_adapter_t"
|
|
|
63 |
|
64 |
|
65 |
class MagicTimeController:
|
66 |
+
def __init__(self, tokenizer, text_encoder, vae, unet, text_model):
|
67 |
|
68 |
# config dirs
|
69 |
self.basedir = os.getcwd()
|
|
|
85 |
# config models
|
86 |
self.inference_config = OmegaConf.load(inference_config_path)[1]
|
87 |
|
88 |
+
# self.tokenizer = CLIPTokenizer.from_pretrained(pretrained_model_path, subfolder="tokenizer")
|
89 |
+
# self.text_encoder = CLIPTextModel.from_pretrained(pretrained_model_path, subfolder="text_encoder").cuda()
|
90 |
+
# self.vae = AutoencoderKL.from_pretrained(pretrained_model_path, subfolder="vae").cuda()
|
91 |
+
# self.unet = UNet3DConditionModel.from_pretrained_2d(pretrained_model_path, subfolder="unet", unet_additional_kwargs=OmegaConf.to_container(self.inference_config.unet_additional_kwargs)).cuda()
|
92 |
+
# self.text_model = CLIPTextModel.from_pretrained("openai/clip-vit-large-patch14")
|
93 |
+
|
94 |
+
self.tokenizer = tokenizer
|
95 |
+
self.text_encoder = text_encoder
|
96 |
+
self.vae = vae
|
97 |
+
self.unet = unet
|
98 |
+
self.text_model = text_model
|
99 |
+
|
100 |
self.update_motion_module(self.motion_module_list[0])
|
101 |
self.update_dreambooth(self.dreambooth_list[0])
|
102 |
|
|
|
196 |
"dreambooth": dreambooth_dropdown,
|
197 |
}
|
198 |
return gr.Video(value=save_sample_path), gr.Json(value=json_config)
|
|
|
|
|
199 |
|
200 |
+
inference_config = OmegaConf.load(inference_config_path)[1]
|
201 |
+
tokenizer = CLIPTokenizer.from_pretrained(pretrained_model_path, subfolder="tokenizer")
|
202 |
+
text_encoder = CLIPTextModel.from_pretrained(pretrained_model_path, subfolder="text_encoder").cuda()
|
203 |
+
vae = AutoencoderKL.from_pretrained(pretrained_model_path, subfolder="vae").cuda()
|
204 |
+
unet = UNet3DConditionModel.from_pretrained_2d(pretrained_model_path, subfolder="unet", unet_additional_kwargs=OmegaConf.to_container(inference_config.unet_additional_kwargs)).cuda()
|
205 |
+
text_model = CLIPTextModel.from_pretrained("openai/clip-vit-large-patch14")
|
206 |
+
controller = MagicTimeController(tokenizer=tokenizer, text_encoder=text_encoder, vae=vae, unet=unet, text_model=text_model)
|
207 |
|
208 |
def ui():
|
209 |
with gr.Blocks(css=css) as demo:
|