Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -173,34 +173,33 @@ def analyze_image_features(image):
|
|
173 |
hsv = cv2.cvtColor(img_cv, cv2.COLOR_BGR2HSV)
|
174 |
hue_std = float(np.std(hsv[:,:,0]))
|
175 |
sat_std = float(np.std(hsv[:,:,1]))
|
176 |
-
val_std = float(np.std(
|
177 |
-
features["saturation_variation"] = sat_std /
|
178 |
-
|
179 |
-
return features
|
180 |
|
181 |
-
def make_final_decision(ai_probability,
|
182 |
-
|
183 |
-
|
184 |
-
base_decision = "
|
185 |
-
elif ai_probability < 0.3:
|
186 |
-
base_decision = "高概率人类创作"
|
187 |
-
|
188 |
|
189 |
# 特征调整
|
190 |
feature_score = 0
|
191 |
|
192 |
-
# 检查对称性 -
|
193 |
-
if "
|
|
|
|
|
|
|
|
|
194 |
|
195 |
-
#
|
196 |
-
if image_features["edge_density"] < 0.01 检查噪声 - AI生成图_features["noise_level"] < 0.3:
|
197 |
-
feature_score += 0.1
|
198 |
|
199 |
-
# 检查颜色变化 - AI生成图像通常颜色变化更平滑 and image_features["hue_variation"] < 0.05
|
200 |
-
if "saturation_variation" in image_features and image_features["saturation_variation"] < 0.1
|
201 |
|
202 |
# 调整最终概率
|
203 |
-
adjusted_probability = min(1.0, max(0.0, ai_probability + feature_score))
|
|
|
|
|
204 |
if adjusted_probability > 0.7:
|
205 |
return "高概率AI生成", adjusted_probability
|
206 |
elif adjusted_probability < 0.3:
|
@@ -283,4 +282,4 @@ iface = gr.Interface(
|
|
283 |
allow_flagging="never"
|
284 |
)
|
285 |
|
286 |
-
iface.launch()
|
|
|
173 |
hsv = cv2.cvtColor(img_cv, cv2.COLOR_BGR2HSV)
|
174 |
hue_std = float(np.std(hsv[:,:,0]))
|
175 |
sat_std = float(np.std(hsv[:,:,1]))
|
176 |
+
val_std = float(np.std(hsv[:,:,2ue_variation"] = hue 归一化
|
177 |
+
features["saturation_variation"] = sat_std / 255 val_std / features
|
|
|
|
|
178 |
|
179 |
+
def make_final_decision(ai_probability, image于AI概率和图像特征做出更准 基础 ai_probability >_decision = "高概率AI生 < 0.3:
|
180 |
+
类创作"
|
181 |
+
else:
|
182 |
+
base_decision = "无法确定"
|
|
|
|
|
|
|
183 |
|
184 |
# 特征调整
|
185 |
feature_score = 0
|
186 |
|
187 |
+
# 检查对称性 - 高对称性通常表示AI生成
|
188 |
+
if "horizontal_symmetry" in image_features and image_features["horizontal_symmetry"]0.1
|
189 |
+
if "vertical_symmetry" in image_features and image_features["vertical_symmetry"] > 0.85:
|
190 |
+
|
191 |
+
|
192 |
+
# 检查边缘 - AI生成图像通常边缘密_density"] < 0.010.1
|
193 |
|
194 |
+
# 检查噪声 - AI生成图像通常噪声较低_level"] < 0.30.1
|
|
|
|
|
195 |
|
196 |
+
# 检查颜色变化 - AI生成图像通常颜色变化更平滑 in image_features and image_features["hue_variation"] < 0.05
|
197 |
+
if "saturation_variation" in image_features and image_features["saturation_variation"] < 0.10.1
|
198 |
|
199 |
# 调整最终概率
|
200 |
+
adjusted_probability = min(1.0, max(0.0, ai_probability + feature_score))
|
201 |
+
|
202 |
+
断
|
203 |
if adjusted_probability > 0.7:
|
204 |
return "高概率AI生成", adjusted_probability
|
205 |
elif adjusted_probability < 0.3:
|
|
|
282 |
allow_flagging="never"
|
283 |
)
|
284 |
|
285 |
+
iface.launch()
|