Private Detector圖片檢測模型
Private Detector 是 Bumble 開源的圖像檢測模型,可以用于檢測色情圖片。內(nèi)部版本已經(jīng)進(jìn)行了大量的重構(gòu),并作為一個(gè)完全開源的項(xiàng)目發(fā)布,以允許更廣泛的社區(qū)使用和微調(diào)他們自己的 Private Detector 模型。你可以下載預(yù)訓(xùn)練的 SavedModel 模型。
模型:
SavedModel 模型可以在 private_detector.zip 中的 save_model/ 目錄中找到。該模型基于 Efficientnet-v2,并在 Bumble 內(nèi)部的數(shù)據(jù)集上進(jìn)行了訓(xùn)練。
推理:
推理是非常簡單的,在 inference.py 中已經(jīng)給出了一個(gè)例子
python3 inference.py \
--model saved_model/ \
--image_paths \
Yes_samples/1.jpg \
Yes_samples/2.jpg \
Yes_samples/3.jpg \
Yes_samples/4.jpg \
Yes_samples/5.jpg \
No_samples/1.jpg \
No_samples/2.jpg \
No_samples/3.jpg \
No_samples/4.jpg \
No_samples/5.jpg \
附加訓(xùn)練
開發(fā)者可以根據(jù)自己的數(shù)據(jù)自行微調(diào)模型,這樣做非常簡單,可以在 private_detector.zip的 saved_checkpoint/目錄中找到所需要的 checkpoint 文件。
設(shè)置一個(gè) JSON 文件,其中包含指向每個(gè)類的圖像路徑列表的鏈接:
{
"Yes": {
"path": "/home/sofarrell/private_detector/Yes.txt",
"label": 0
},
"No": {
"path": "/home/sofarrell/private_detector/No.txt",
"label": 1
}
}
與每個(gè)列出圖像的圖像路徑的.txt文件
/home/sofarrell/private_detector_images/Yes/1093840880_309463828.jpg /home/sofarrell/private_detector_images/Yes/657954182_3459624.jpg /home/sofarrell/private_detector_images/Yes/1503714421_3048734.jpg
可以使用 conda 創(chuàng)建訓(xùn)練環(huán)境:
conda env create -f environment.yaml conda activate private_detector
然后像這樣重新訓(xùn)練:
python3 ./train.py \
--train_json /home/sofarrell/private_detector/train_classes.json \
--eval_json /home/sofarrell/private_detector/eval_classes.json \
--checkpoint_dir saved_checkpoint/ \
--train_id retrained_private_detector
評論
圖片
表情
