Instructions to use Genlook/tryon-safety-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- OpenCLIP
How to use Genlook/tryon-safety-classifier with OpenCLIP:
import open_clip model, preprocess_train, preprocess_val = open_clip.create_model_and_transforms('hf-hub:Genlook/tryon-safety-classifier') tokenizer = open_clip.get_tokenizer('hf-hub:Genlook/tryon-safety-classifier') - Notebooks
- Google Colab
- Kaggle
Try-On Safety Classifier
Decides, from product photos, what a virtual try-on of that product would show. Built by Genlook to gate garments before they are rendered onto a shopper's photo.
Join the Discord for support, false-positive reports and feedback · Genlook Try-On API to add virtual try-on to a store or an app
It answers one question per product: if a shopper tries this on, how much skin or sexual content ends up in the result? That is different from a generic NSFW detector, which judges the pixels of the product photo. A lingerie flat lay has no nudity in it, but the try-on result would show the shopper in lingerie. A fetish mask on a mannequin is not explicit, but it is still a sexual product.
Outputs
| Head | Values |
|---|---|
level |
ok, revealing, lingerie, adult (ordered by severity) |
subject |
human_clothing, pet, not_clothing |
swimwear |
not_swimwear, regular, near_micro, micro |
ravewear |
true or false |
Levels
- ok: the shopper is shown normally dressed. Everyday clothing, sportswear, full-coverage costumes and cosplay, wetsuits, accessories and non-clothing items.
- revealing: swimwear-level coverage. Bikinis and swimsuits (including string and thong cuts that still cover), men's underwear, shapewear, cover-ups over swimwear, micro skirts and shorts, most festival and rave outfits.
- lingerie: women's underwear and lingerie where nothing intimate is clearly visible. Bras, bralettes, panties and thongs, lingerie sets, bodysuits, teddies, babydolls, garters, stockings, corsets.
- adult: intimate areas exposed, or a sexual product. Swimwear that barely covers the nipples or genitals, pasties and nipple covers, body chains worn on bare skin, see-through pieces with nipples or genitals clearly visible, open-cup and crotchless designs, BDSM and fetish wear (including leather or latex restraints, harnesses, collars, hoods, pup-play gear and fetish suits), sexual role-play costumes, sexualised anime outfits, anything revealing shown on a drawn or anime figure, sex toys, and nudity used as a product shot.
The full rules, with a table of hard cases, are in LABELLING_POLICY.md.
Tags
- subject: what the product is made for. Pet harnesses and pet clothes are
pet. Cosmetics, wigs, home goods and other items you cannot wear as clothing arenot_clothing. - swimwear: coverage of real swimwear only.
regularis ordinary bikini or swimsuit coverage,near_microis a small but complete cut (string, thong or G-string bikinis, small cups),microbarely covers the nipples or genitals.regularandnear_microarerevealing;microisadult. - ravewear: festival and rave outfits (rave bras and bodysuits, fishnet or rhinestone festival sets, chain tops, holographic pieces). It does not change the level. Pasties on their own and swimwear made of rave materials are not ravewear.
Usage
# pip install torch open_clip_torch safetensors huggingface_hub pillow
from huggingface_hub import hf_hub_download
import importlib.util
spec = importlib.util.spec_from_file_location("tryon_safety", hf_hub_download("Genlook/tryon-safety-classifier", "tryon_safety.py"))
tryon_safety = importlib.util.module_from_spec(spec); spec.loader.exec_module(tryon_safety)
clf = tryon_safety.TryOnSafetyClassifier.from_pretrained("Genlook/tryon-safety-classifier")
pred = clf.predict(["front.jpg", "back.jpg"]) # all photos of one product
print(pred.level, pred.blocked, pred.probs, pred.subject, pred.swimwear, pred.ravewear)
Pass every photo you have of a product: the score is computed over all of them. Use pred.blocked
(P(adult) at or above the threshold in config.json, 0.3 by default) rather than the top level when you need a safety
gate, because it catches more adult products for a small increase in false blocks.
Variants
| Variant | Folder | Size | When to use |
|---|---|---|---|
finetuned (default) |
repo root | about 0.9 GB | Best at catching adult products, especially leather, BDSM and fetish items |
frozen |
frozen/ |
about 120 KB on top of the public SigLIP 2 weights | Lighter, easy to retrain; misses slightly more adult products |
clf = tryon_safety.TryOnSafetyClassifier.from_pretrained("Genlook/tryon-safety-classifier", variant="frozen")
Pin a release with revision="v1.0" so an update never changes your results without you choosing it.
Evaluation
5-fold cross-validation over 2,596 products (about 5,000 photos): every product is scored by a model that never saw it.
| finetuned | frozen | |
|---|---|---|
| Accuracy (4 levels) | 94.6% | 94.2% |
| Adult products missed, top level | 53 of 534 | 53 of 534 |
| False adult, top level | 34 | 41 |
| Adult products missed, threshold 0.3 | 34 of 534 | 39 of 534 |
| False adult, threshold 0.3 | 52 | 55 |
| Lingerie recall | 90% | 89% |
| Subject accuracy | 99.2% | |
| Swimwear tag accuracy | 90.0% | |
| Ravewear tag accuracy | 95.3% (recall 72%) |
By product group (finetuned, top level):
| Group | Products | Accuracy | Adult missed |
|---|---|---|---|
| Everyday fashion catalogs | 1,032 | 97.5% | 10 of 77 |
| Exotic and micro swimwear | 330 | 91.8% | 13 of 106 |
| Swimwear brands | 230 | 95.2% | 4 of 4 |
| Lingerie brands | 120 | 94.2% | 3 of 4 |
| Festival and rave | 115 | 85.2% | 4 of 15 |
| Rope and bondage | 75 | 100% | 0 of 75 |
| Anime and cosplay | 63 | 93.7% | 1 of 16 |
| Fetish, lingerie and pet catalogs | 631 | 92.6% | 18 of 237 |
True micro swimwear: 91 of 95 caught.
Training data
About 2,600 garment and accessory products, from product photos of online shop catalogs, chosen to cover the hard cases (lingerie, micro swimwear, fetish wear, festival wear, cosplay, pet wear). Only product photos are used, never photos of shoppers.
Labels follow a written policy, published in LABELLING_POLICY.md. A large language model (Claude) labelled every product after looking at every photo, and a human reviewer corrected the boundary cases. The dataset is not released.
Limitations
- The hardest boundary is sheer lingerie: whether nipples or genitals are clearly visible decides between
lingerieandadult, and look-alike products are close. Most remaining errors are there. - Festival and rave wear is the weakest group: fishnet, mesh and rhinestones push the model towards
adult. - The levels describe what a try-on result would show. They are not a judgement of the product or the shop, and the
right gate depends on your audience: some stores allow
lingerie, some blockrevealing. - Trained mostly on western e-commerce photography. Expect lower accuracy on very different photo styles.
- Do not use it to identify or make decisions about people. It classifies products.
Model details
- Base: SigLIP 2 so400m, patch 16, 384 px (Apache-2.0).
finetuned: last 6 transformer blocks and the attention-pool head trained end to end for 6 epochs with four linear heads, class-balanced loss, random crop, flip and colour jitter.frozen: the base tower unchanged, logistic-regression heads on the mean and max of the photo embeddings.- Weights are stored as safetensors. Inference needs
open_clipandtorchonly.
Changelog
- v1.0: first release. Four levels, subject, swimwear and ravewear heads.
Support and community
Questions, false positives you want to report, or ideas for the next version: join the Genlook Discord or open a discussion on this repo.
Building virtual try-on into a store or an app? See the Genlook Try-On API.
License
Apache-2.0, like the base model.
- Downloads last month
- -
Model tree for Genlook/tryon-safety-classifier
Base model
timm/ViT-SO400M-16-SigLIP2-384