Vivien Chappelier
set model commit_hash
e3f5433
raw
history blame
597 Bytes
from transformers import AutoModel, BlipImageProcessor
from PIL import Image
import sys
import torch
image_processor = BlipImageProcessor.from_pretrained("imatag/stable-signature-bzh-detector-resnet18")
commit_hash = "584a7bc01dc0f02e53bf8b8b295717ed09ed7294"
model = AutoModel.from_pretrained("imatag/stable-signature-bzh-detector-resnet18", trust_remote_code=True, revision=commit_hash)
img = Image.open(sys.argv[1]).convert("RGB")
inputs = image_processor(img, return_tensors="pt")
with torch.no_grad():
p = torch.sigmoid(model(**inputs).logits).item()
print(f"approximate p-value: {p}")