Instructions to use makactuary/simba-or-not with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use makactuary/simba-or-not with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("makactuary/simba-or-not", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - timm
How to use makactuary/simba-or-not with timm:
import timm model = timm.create_model("hf-hub:makactuary/simba-or-not", pretrained=True) - Notebooks
- Google Colab
- Kaggle
Download predict.py from makactuary/simba-or-not: direct link, hf CLI and curl.
- Browser
- Download file 816 Bytes
-
https://huggingface.co/makactuary/simba-or-not/resolve/main/predict.py
- Command line
-
hf download hf://makactuary/simba-or-not/predict.py
-
curl -L -o predict.py https://huggingface.co/makactuary/simba-or-not/resolve/main/predict.py
816 Bytes
| """Is this Simba? ConvNeXt-Tiny features (timm) + logistic-regression head.""" | |
| import sys | |
| import joblib, timm, torch | |
| from PIL import Image, ImageOps | |
| from huggingface_hub import hf_hub_download | |
| head = joblib.load(hf_hub_download("makactuary/simba-or-not", "head.joblib")) | |
| backbone = timm.create_model("convnext_tiny.fb_in22k_ft_in1k", pretrained=True, num_classes=0).eval() | |
| transform = timm.data.create_transform(**timm.data.resolve_data_config({}, model=backbone)) | |
| def is_simba(path): | |
| with torch.inference_mode(): | |
| x = backbone(transform(ImageOps.exif_transpose(Image.open(path)).convert("RGB")).unsqueeze(0)).numpy() | |
| p = float(head.predict_proba(x)[0, 1]) | |
| return ("Simba" if p >= 0.5 else "not Simba"), round(p, 3) | |
| if __name__ == "__main__": | |
| print(is_simba(sys.argv[1])) | |