Spaces:
Running
Running
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -5,6 +5,8 @@ from io import BytesIO
|
|
| 5 |
from pathlib import Path
|
| 6 |
from PIL import Image
|
| 7 |
from functools import lru_cache
|
|
|
|
|
|
|
| 8 |
|
| 9 |
_MODEL_CACHE: Dict[str, Any] = {}
|
| 10 |
|
|
@@ -73,7 +75,6 @@ def prepare_examples():
|
|
| 73 |
def load_model(model_id: str, token: str | None = None) -> Any:
|
| 74 |
"""Load model with caching."""
|
| 75 |
if model_id not in _MODEL_CACHE:
|
| 76 |
-
from moderators.auto_model import AutoModerator
|
| 77 |
_MODEL_CACHE[model_id] = AutoModerator.from_pretrained(model_id, token=token, use_fast=True)
|
| 78 |
return _MODEL_CACHE[model_id]
|
| 79 |
|
|
|
|
| 5 |
from pathlib import Path
|
| 6 |
from PIL import Image
|
| 7 |
from functools import lru_cache
|
| 8 |
+
from moderators import AutoModerator
|
| 9 |
+
|
| 10 |
|
| 11 |
_MODEL_CACHE: Dict[str, Any] = {}
|
| 12 |
|
|
|
|
| 75 |
def load_model(model_id: str, token: str | None = None) -> Any:
|
| 76 |
"""Load model with caching."""
|
| 77 |
if model_id not in _MODEL_CACHE:
|
|
|
|
| 78 |
_MODEL_CACHE[model_id] = AutoModerator.from_pretrained(model_id, token=token, use_fast=True)
|
| 79 |
return _MODEL_CACHE[model_id]
|
| 80 |
|