diff --git a/README.md b/README.md index ee2711d..620b2a0 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ CatismImage 是一个基于Web的图片存储和管理系统,提供用户友 # NSFW过滤配置(目前支持NSFWPY) ENABLE_NSFW_FILTER=true/false NSFWPY_ENDPOINT=your_nsfwpy_endpoint + NSFWPY_THRESHOLD=0.5 ``` 6. 运行后端服务: diff --git a/config.py b/config.py index 69c084d..05374e4 100644 --- a/config.py +++ b/config.py @@ -18,6 +18,7 @@ class Config: ENABLE_NSFW_FILTER = os.getenv('ENABLE_NSFW_FILTER') NSFWPY_ENDPOINT = os.getenv('NSFWPY_ENDPOINT') + NSFWPY_THRESHOLD = os.getenv('NSFWPY_THRESHOLD') if(S3_ACCESS_KEY == None or S3_SECRET_KEY == None or S3_BUCKET == None or S3_ENDPOINT == None): print("错误:缺少必需的S3环境变量") diff --git a/routes/images.py b/routes/images.py index 2316703..c326668 100644 --- a/routes/images.py +++ b/routes/images.py @@ -77,8 +77,8 @@ def upload_image(): nsfw_data = response.json() # 检查NSFW评分 - if nsfw_data.get('neutral', 0) + nsfw_data.get('drawing', 0) < 0.5: - return jsonify({'error': '图片内容不符合安全标准'}), 403 + if nsfw_data.get('neutral', 0) + nsfw_data.get('drawing', 0) < 1 - AppConfig.NSFWPY_THRESHOLD: + return jsonify({'error': '图片内容未通过NSFW检查'}), 403 file.seek(0) except Exception as e: