Spaces:
Sleeping
Sleeping
upgrade versions of gradio and rest of libraries
Browse files
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🎧
|
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: gray
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: cc-by-sa-4.0
|
|
|
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: gray
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 6.19.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: cc-by-sa-4.0
|
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import os
|
|
| 3 |
if os.getenv('SPACES_ZERO_GPU') == "true":
|
| 4 |
os.environ['SPACES_ZERO_GPU'] = "1"
|
| 5 |
|
|
|
|
| 6 |
import gradio as gr
|
| 7 |
import random
|
| 8 |
import torch
|
|
@@ -12,7 +13,6 @@ from typing import Optional, List
|
|
| 12 |
import numpy as np
|
| 13 |
from models import load_model
|
| 14 |
import utils
|
| 15 |
-
import spaces
|
| 16 |
import huggingface_hub
|
| 17 |
from inversion_utils import inversion_forward_process, inversion_reverse_process
|
| 18 |
|
|
@@ -322,7 +322,7 @@ to <code style="display:inline; background-color: lightgrey;">None</code>.
|
|
| 322 |
|
| 323 |
"""
|
| 324 |
|
| 325 |
-
css = '.gradio-container {
|
| 326 |
'.audio-upload .wrap {min-height: 0px;}'
|
| 327 |
|
| 328 |
# with gr.Blocks(css='style.css') as demo:
|
|
@@ -383,7 +383,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 383 |
|
| 384 |
with gr.Accordion("More Options", open=False):
|
| 385 |
with gr.Row():
|
| 386 |
-
src_prompt = gr.Textbox(label="Source Prompt", lines=2, interactive=True,
|
| 387 |
info="Optional: Describe the original audio input",
|
| 388 |
placeholder="A recording of a happy upbeat classical music piece",)
|
| 389 |
|
|
|
|
| 3 |
if os.getenv('SPACES_ZERO_GPU') == "true":
|
| 4 |
os.environ['SPACES_ZERO_GPU'] = "1"
|
| 5 |
|
| 6 |
+
import spaces
|
| 7 |
import gradio as gr
|
| 8 |
import random
|
| 9 |
import torch
|
|
|
|
| 13 |
import numpy as np
|
| 14 |
from models import load_model
|
| 15 |
import utils
|
|
|
|
| 16 |
import huggingface_hub
|
| 17 |
from inversion_utils import inversion_forward_process, inversion_reverse_process
|
| 18 |
|
|
|
|
| 322 |
|
| 323 |
"""
|
| 324 |
|
| 325 |
+
css = '.gradio-container {padding-top: 1.5rem !important;}' \
|
| 326 |
'.audio-upload .wrap {min-height: 0px;}'
|
| 327 |
|
| 328 |
# with gr.Blocks(css='style.css') as demo:
|
|
|
|
| 383 |
|
| 384 |
with gr.Accordion("More Options", open=False):
|
| 385 |
with gr.Row():
|
| 386 |
+
src_prompt = gr.Textbox(label="Source Prompt", lines=2, interactive=True, value="",
|
| 387 |
info="Optional: Describe the original audio input",
|
| 388 |
placeholder="A recording of a happy upbeat classical music piece",)
|
| 389 |
|
models.py
CHANGED
|
@@ -2,7 +2,7 @@ import torch
|
|
| 2 |
from diffusers import DDIMScheduler, CosineDPMSolverMultistepScheduler
|
| 3 |
from diffusers.schedulers.scheduling_dpmsolver_sde import BrownianTreeNoiseSampler
|
| 4 |
from diffusers import AudioLDM2Pipeline, StableAudioPipeline
|
| 5 |
-
from transformers import RobertaTokenizer, RobertaTokenizerFast, VitsTokenizer
|
| 6 |
from diffusers.models.unets.unet_2d_condition import UNet2DConditionOutput
|
| 7 |
from diffusers.models.embeddings import get_1d_rotary_pos_embed
|
| 8 |
from typing import Any, Dict, List, Optional, Tuple, Union
|
|
@@ -178,14 +178,26 @@ class AudioLDM2Wrapper(PipelineWrapper):
|
|
| 178 |
def __init__(self, *args, **kwargs) -> None:
|
| 179 |
super().__init__(*args, **kwargs)
|
| 180 |
if self.double_precision:
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
).to(self.device)
|
| 183 |
else:
|
| 184 |
try:
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
).to(self.device)
|
| 187 |
except FileNotFoundError:
|
| 188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
).to(self.device)
|
| 190 |
|
| 191 |
def load_scheduler(self) -> None:
|
|
@@ -262,6 +274,10 @@ class AudioLDM2Wrapper(PipelineWrapper):
|
|
| 262 |
text_input_ids,
|
| 263 |
attention_mask=attention_mask,
|
| 264 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
# append the seq-len dim: (bs, hidden_size) -> (bs, seq_len, hidden_size)
|
| 266 |
prompt_embeds = prompt_embeds[:, None, :]
|
| 267 |
# make sure that we attend to this single hidden-state
|
|
|
|
| 2 |
from diffusers import DDIMScheduler, CosineDPMSolverMultistepScheduler
|
| 3 |
from diffusers.schedulers.scheduling_dpmsolver_sde import BrownianTreeNoiseSampler
|
| 4 |
from diffusers import AudioLDM2Pipeline, StableAudioPipeline
|
| 5 |
+
from transformers import RobertaTokenizer, RobertaTokenizerFast, VitsTokenizer, GPT2LMHeadModel
|
| 6 |
from diffusers.models.unets.unet_2d_condition import UNet2DConditionOutput
|
| 7 |
from diffusers.models.embeddings import get_1d_rotary_pos_embed
|
| 8 |
from typing import Any, Dict, List, Optional, Tuple, Union
|
|
|
|
| 178 |
def __init__(self, *args, **kwargs) -> None:
|
| 179 |
super().__init__(*args, **kwargs)
|
| 180 |
if self.double_precision:
|
| 181 |
+
language_model = GPT2LMHeadModel.from_pretrained(self.model_id, subfolder="language_model",
|
| 182 |
+
local_files_only=True, token=self.token,
|
| 183 |
+
torch_dtype=torch.float64)
|
| 184 |
+
self.model = AudioLDM2Pipeline.from_pretrained(self.model_id, torch_dtype=torch.float64, token=self.token,
|
| 185 |
+
language_model=language_model,
|
| 186 |
).to(self.device)
|
| 187 |
else:
|
| 188 |
try:
|
| 189 |
+
language_model = GPT2LMHeadModel.from_pretrained(self.model_id, subfolder="language_model",
|
| 190 |
+
local_files_only=True, token=self.token,
|
| 191 |
+
torch_dtype=torch.float32)
|
| 192 |
+
self.model = AudioLDM2Pipeline.from_pretrained(self.model_id, local_files_only=True, token=self.token,
|
| 193 |
+
torch_dtype=torch.float32, language_model=language_model,
|
| 194 |
).to(self.device)
|
| 195 |
except FileNotFoundError:
|
| 196 |
+
language_model = GPT2LMHeadModel.from_pretrained(self.model_id, subfolder="language_model",
|
| 197 |
+
local_files_only=False, token=self.token,
|
| 198 |
+
torch_dtype=torch.float32)
|
| 199 |
+
self.model = AudioLDM2Pipeline.from_pretrained(self.model_id, local_files_only=False, token=self.token,
|
| 200 |
+
torch_dtype=torch.float32, language_model=language_model,
|
| 201 |
).to(self.device)
|
| 202 |
|
| 203 |
def load_scheduler(self) -> None:
|
|
|
|
| 274 |
text_input_ids,
|
| 275 |
attention_mask=attention_mask,
|
| 276 |
)
|
| 277 |
+
# Extract the pooler output if it's a BaseModelOutputWithPooling (Transformers v5+)
|
| 278 |
+
# otherwise use it directly (Transformers v4)
|
| 279 |
+
if hasattr(prompt_embeds, 'pooler_output'):
|
| 280 |
+
prompt_embeds = prompt_embeds.pooler_output
|
| 281 |
# append the seq-len dim: (bs, hidden_size) -> (bs, seq_len, hidden_size)
|
| 282 |
prompt_embeds = prompt_embeds[:, None, :]
|
| 283 |
# make sure that we attend to this single hidden-state
|
requirements.txt
CHANGED
|
@@ -11,3 +11,5 @@ progressbar
|
|
| 11 |
einops
|
| 12 |
scipy
|
| 13 |
librosa==0.9.2
|
|
|
|
|
|
|
|
|
| 11 |
einops
|
| 12 |
scipy
|
| 13 |
librosa==0.9.2
|
| 14 |
+
soxr
|
| 15 |
+
torchcodec
|