Spaces:
Sleeping
Sleeping
Commit ·
8933f68
1
Parent(s): 83e68e1
Increase pyannote batch sizes to 64
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
import json
|
|
|
|
| 4 |
import subprocess
|
| 5 |
import tempfile
|
| 6 |
import time
|
|
@@ -21,6 +22,17 @@ torch.backends.cudnn.allow_tf32 = True
|
|
| 21 |
_PIPELINE: Pipeline | None = None
|
| 22 |
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
def get_pipeline(hf_token: str) -> Pipeline:
|
| 25 |
global _PIPELINE
|
| 26 |
|
|
@@ -35,6 +47,7 @@ def get_pipeline(hf_token: str) -> Pipeline:
|
|
| 35 |
local_dir=str(local_model_dir),
|
| 36 |
)
|
| 37 |
|
|
|
|
| 38 |
_PIPELINE = Pipeline.from_pretrained(str(local_model_dir))
|
| 39 |
return _PIPELINE
|
| 40 |
|
|
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
import json
|
| 4 |
+
import re
|
| 5 |
import subprocess
|
| 6 |
import tempfile
|
| 7 |
import time
|
|
|
|
| 22 |
_PIPELINE: Pipeline | None = None
|
| 23 |
|
| 24 |
|
| 25 |
+
def _set_local_batch_sizes(local_model_dir: Path) -> None:
|
| 26 |
+
config_path = local_model_dir / "config.yaml"
|
| 27 |
+
if not config_path.exists():
|
| 28 |
+
return
|
| 29 |
+
|
| 30 |
+
config_text = config_path.read_text(encoding="utf-8")
|
| 31 |
+
config_text = re.sub(r"(segmentation_batch_size:\s*)\d+", r"\g<1>64", config_text)
|
| 32 |
+
config_text = re.sub(r"(embedding_batch_size:\s*)\d+", r"\g<1>64", config_text)
|
| 33 |
+
config_path.write_text(config_text, encoding="utf-8")
|
| 34 |
+
|
| 35 |
+
|
| 36 |
def get_pipeline(hf_token: str) -> Pipeline:
|
| 37 |
global _PIPELINE
|
| 38 |
|
|
|
|
| 47 |
local_dir=str(local_model_dir),
|
| 48 |
)
|
| 49 |
|
| 50 |
+
_set_local_batch_sizes(local_model_dir)
|
| 51 |
_PIPELINE = Pipeline.from_pretrained(str(local_model_dir))
|
| 52 |
return _PIPELINE
|
| 53 |
|