Downloads · 30 days
0
Bjoon/lh-nsfw-dp-detector
lh-nsfw-dp-detector is a object detection model from Bjoon. Use it when you need objects located in an image. The card lists the license as cc-by-nc-nd-4.0.
Real-time object detection model based on RT-DETRv4 with HGNetv2-B4 backbone, trained on a custom 2-class NSFW detection dataset.
Downloads · 30 days
0
Access
Public
Updated Feb 17, 2026
Repo size
1.5 GB
Likes
1
Public
Click a slice to open those files.
.pth1.5 GB · 100%
From the Hugging Face model README
Real-time object detection model based on RT-DETRv4 with HGNetv2-B4 backbone, trained on a custom 2-class NSFW detection dataset.
| Property | Value |
|---|---|
| Architecture | RT-DETRv4 (D-FINE decoder + VFM distillation) |
| Backbone | HGNetv2-B4 |
| Parameters | ~31.3M |
| Input Size | 640 x 640 |
| Classes | 2 (male, female) |
| Best AP (val) | 43.15 |
| Training | Two-stage with Mosaic/Mixup augmentation + DINOv3 distillation |
git clone https://huggingface.co/Bjoon/lh-nsfw-dp-detector
cd lh-nsfw-dp-detector
pip install -r requirements.txt
import torch
import torch.nn as nn
import torchvision.transforms as T
from PIL import Image
from engine.core import YAMLConfig
# Load config and checkpoint
cfg = YAMLConfig("configs/rtv4/rtv4_hgnetv2_l_coco.yml", resume="best_stg1.pth")
cfg.yaml_cfg['HGNetv2']['pretrained'] = False
checkpoint = torch.load("best_stg1.pth", map_location="cpu")
state = checkpoint['ema']['module'] if 'ema' in checkpoint else checkpoint['model']
cfg.model.load_state_dict(state)
class Model(nn.Module):
def __init__(self):
super().__init__()
self.model = cfg.model.deploy()
self.postprocessor = cfg.postprocessor.deploy()
def forward(self, images, orig_target_sizes):
outputs = self.model(images)
return self.postprocessor(outputs, orig_target_sizes)
model = Model().to("cuda").eval()
# Run inference
im = Image.open("test.jpg").convert("RGB")
w, h = im.size
transforms = T.Compose([
T.Resize((640, 640)),
T.ToTensor(),
T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
])
im_data = transforms(im).unsqueeze(0).to("cuda")
orig_size = torch.tensor([[w, h]]).to("cuda")
labels, boxes, scores = model(im_data, orig_size)
python tools/inference/torch_inf.py \
-c configs/rtv4/rtv4_hgnetv2_l_coco.yml \
-r best_stg1.pth \
--input image.jpg \
--device cuda:0
├── best_stg1.pth # Model checkpoint
├── configs/ # YAML config chain
│ ├── rtv4/rtv4_hgnetv2_l_coco.yml
│ ├── dfine/dfine_hgnetv2_l_coco.yml
│ ├── base/{dfine_hgnetv2,optimizer,dataloader,rtv4}.yml
│ ├── dataset/{custom_detection,coco_detection}.yml
│ └── runtime.yml
├── engine/ # Model + inference code
├── tools/inference/torch_inf.py # Inference script
└── requirements.txt
CC BY-NC-ND 4.0 (Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International)
This model is provided for non-commercial research and personal use only. Commercial use of any kind is strictly prohibited, including but not limited to:
For any questions regarding licensing, please contact the author.