CoolFace
Apppublic

mkmanish/truthmark-api

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
model_loader.py23 linesDownload Raw Back to root
1import tensorflow as tf2from transformers import RobertaTokenizer3from huggingface_hub import snapshot_download4from pathlib import Path5 6MODEL_REPO = "mkmanish/truthmark-roberta-ai-detector"7 8print("Downloading model from Hugging Face Hub...")9model_path = snapshot_download(repo_id=MODEL_REPO)10 11ARTIFACT_DIR = Path(model_path)12 13MAX_LENGTH = 512  # same as training14 15print("Loading tokenizer...")16tokenizer = RobertaTokenizer.from_pretrained(str(ARTIFACT_DIR / "tokenizer"), use_fast=False)17 18print("Loading full SavedModel...")19_loaded = tf.saved_model.load(str(ARTIFACT_DIR / "truthmark_full_model"))20infer = _loaded.signatures["serve"]21 22print("Model loaded successfully.")23