Update app.py
Browse files
app.py
CHANGED
|
@@ -5,12 +5,15 @@ import torch
|
|
| 5 |
# import librosa
|
| 6 |
import torchaudio
|
| 7 |
from diffusers import DDIMScheduler
|
| 8 |
-
from transformers import AutoProcessor, ClapModel
|
| 9 |
from model.udit import UDiT
|
| 10 |
from vae_modules.autoencoder_wrapper import Autoencoder
|
| 11 |
import numpy as np
|
| 12 |
-
|
|
|
|
|
|
|
| 13 |
|
|
|
|
| 14 |
# snapshot_download(repo_id="laion/larger_clap_general",
|
| 15 |
# local_dir="./larger_clap_general",
|
| 16 |
# local_dir_use_symlinks=False)
|
|
@@ -27,8 +30,14 @@ with open(diffusion_config, 'r') as fp:
|
|
| 27 |
|
| 28 |
v_prediction = diff_config["ddim"]["v_prediction"]
|
| 29 |
|
| 30 |
-
clapmodel = ClapModel.from_pretrained("laion/larger_clap_general").to(device)
|
| 31 |
processor = AutoProcessor.from_pretrained('laion/larger_clap_general')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
autoencoder = Autoencoder(autoencoder_path, 'stable_vae', quantization_first=True)
|
| 33 |
autoencoder.eval()
|
| 34 |
autoencoder.to(device)
|
|
|
|
| 5 |
# import librosa
|
| 6 |
import torchaudio
|
| 7 |
from diffusers import DDIMScheduler
|
| 8 |
+
from transformers import AutoProcessor, ClapModel, ClapConfig
|
| 9 |
from model.udit import UDiT
|
| 10 |
from vae_modules.autoencoder_wrapper import Autoencoder
|
| 11 |
import numpy as np
|
| 12 |
+
from huggingface_hub import hf_hub_download
|
| 13 |
+
|
| 14 |
+
clap_bin_path = hf_hub_download("laion/larger_clap_general", "pytorch_model.bin")
|
| 15 |
|
| 16 |
+
# from huggingface_hub import snapshot_download
|
| 17 |
# snapshot_download(repo_id="laion/larger_clap_general",
|
| 18 |
# local_dir="./larger_clap_general",
|
| 19 |
# local_dir_use_symlinks=False)
|
|
|
|
| 30 |
|
| 31 |
v_prediction = diff_config["ddim"]["v_prediction"]
|
| 32 |
|
| 33 |
+
# clapmodel = ClapModel.from_pretrained("laion/larger_clap_general").to(device)
|
| 34 |
processor = AutoProcessor.from_pretrained('laion/larger_clap_general')
|
| 35 |
+
clap_config = ClapConfig.from_pretrained("laion/larger_clap_general") # 只下载 config.json(或用本地路径)
|
| 36 |
+
clapmodel = ClapModel(config)
|
| 37 |
+
clap_ckpt = torch.load(clap_bin_path, map_location='cpu')
|
| 38 |
+
clapmodel.load_state_dict(clap_ckpt)
|
| 39 |
+
clapmodel.to(device)
|
| 40 |
+
|
| 41 |
autoencoder = Autoencoder(autoencoder_path, 'stable_vae', quantization_first=True)
|
| 42 |
autoencoder.eval()
|
| 43 |
autoencoder.to(device)
|