Text Classification
Transformers
Safetensors
Chinese
spam-detection
advertising-detection
ad-classification
chinese
modernbert
mmbert
multi-task
four-head
Instructions to use x6nux/laya-ad with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use x6nux/laya-ad with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="x6nux/laya-ad")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("x6nux/laya-ad", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download code/laya-server/backend/server/config.py from x6nux/laya-ad: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/x6nux/laya-ad/resolve/main/code/laya-server/backend/server/config.py
- Command line
-
hf download hf://x6nux/laya-ad/code/laya-server/backend/server/config.py
-
curl -L -o config.py https://huggingface.co/x6nux/laya-ad/resolve/main/code/laya-server/backend/server/config.py
1.44 kB
| import os | |
| from dataclasses import dataclass | |
| from pathlib import Path | |
| from argon2 import PasswordHasher | |
| class Settings: | |
| admin_username: str | |
| admin_password_hash: str | |
| database_path: Path | |
| session_hours: int | |
| model_dir: Path | |
| device: str | None | |
| frontend_dir: Path | |
| def from_env(cls) -> "Settings": | |
| username = os.environ.get("LAYA_ADMIN_USERNAME", "") | |
| password = os.environ.get("LAYA_ADMIN_PASSWORD", "") | |
| password_hash = os.environ.get("LAYA_ADMIN_PASSWORD_HASH", "") | |
| if not username: | |
| raise RuntimeError("Set LAYA_ADMIN_USERNAME") | |
| if bool(password) == bool(password_hash): | |
| raise RuntimeError("Set exactly one of LAYA_ADMIN_PASSWORD or LAYA_ADMIN_PASSWORD_HASH") | |
| if password: | |
| if len(password) < 10: | |
| raise RuntimeError("LAYA_ADMIN_PASSWORD must contain at least 10 characters") | |
| password_hash = PasswordHasher().hash(password) | |
| return cls( | |
| username, password_hash, | |
| Path(os.environ.get("LAYA_DATABASE_PATH", "/data/laya.sqlite3")), | |
| int(os.environ.get("LAYA_SESSION_HOURS", "12")), | |
| Path(os.environ.get("LAYA_MODEL_DIR", "/models")), | |
| os.environ.get("LAYA_DEVICE") or None, | |
| Path(os.environ.get("LAYA_FRONTEND_DIR", "/app/frontend/dist")), | |
| ) | |