Downloads · 30 days
0
starlette/img_nsfw
img_nsfw is a machine learning model from starlette. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Downloads · 30 days
0
Access
Public
Updated Oct 23, 2024
Repo size
28 MB
Likes
1
Public
Click a slice to open those files.
.onnx23.7 MB · 83%
From the Hugging Face model README

pip install -r requirements.txt
# 使用自定义模型
nsfw_custom = setup_nsfw(os.path.join(settings_aiplugs.MODELS_DIR, 'you_new_.onnx'))
# 使用默认模型[使用默认模型即可,很精准]
nsfw = setup_nsfw()
# 测试图片路径 【支持base64】
image = '/path/to/image.jpg'
# 返回归一化的结果[0-1之间]float, 越接近1就越少儿不宜
result_ndh = nsfw.nsfw_risk_ndh(image)
print(f"result image: {result_ndh}")
# 返回 True 或者 False T就是少儿不宜
result_tf = nsfw.nsfw_risk_tf(image)
print(f"result image: {result_tf}")
nsfw_risk_tf: 返回一个布尔值,表示图像是否被认为是 NSFW(非安全内容)。 nsfw_risk_ndh: 返回一个概率值,表示图像被认为是 NSFW 的概率。
nsfw_risk_ndh 方法 input_image: 输入图像的路径、Base64 编码字符串或 PIL.Image.Image 对象。 threshold: 阈值,默认为 0.8,用于判断图像是否被认为是 NSFW。
nsfw_risk_tf 方法 input_image: 输入图像的路径、Base64 编码字符串或 PIL.Image.Image 对象。
from nsfw.nsfw_service import setup_nsfw
classifier = setup_nsfw() # 使用默认模型路径
# 测试图片路径
image = '/path/to/image.jpg'
result = classifier.nsfw_risk_ndh(image)
result2 = classifier.nsfw_risk_tf(image)
print(f"result image: {result}")
print(f"result image2: {result2}")
print("-" * 40)
许可证 此项目采用 MIT 许可证。详情参见 LICENSE 文件。
如有任何问题或建议, 请联系:




This repository is licensed under the LINCESE
如果您在研究或项目中使用了 ai_plugs,请考虑引用我们的工作。您可以使用以下BibTeX条目:
@misc{li2024aiplugs, author = {李权威}, title = {{ai_plugs}: 人工智能工具集合}, month = oct, year = 2024, howpublished = {\url{https://github.com/JingYuTech/nsfw}}, note = {Accessed: 2024-10-23} }