aaappp7878 commited on
Commit
28f396b
·
verified ·
1 Parent(s): b015f71

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -15
app.py CHANGED
@@ -173,29 +173,34 @@ 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(hsv[:,:,2]))"] = hue_std / 180 # 归一化
177
- features["saturation_variation"] =_variation"] = val_std /_final_decision(ai_probability, image率和图像特征做出更准确的决策础决策
 
 
 
 
 
178
  if ai_probability > 0.7:
179
- base_decision = "高概率AI生 < 0.3:
180
- base_decision = "高概率人类创 "无法确定"
 
181
 
182
-
183
- feature_score = 0
184
 
185
- # 检查对称性 - 高对称性通常表示AI" in image_features and image_features["horizontal_symmetry"] > 0.0.1
186
- if "vertical_symmetry" in image_features and image_features["vertical_symmetry"] > 0. 0.1
187
 
188
- - AI生成图像通常边缘密度较低
189
- if image_features["edge_density"] < 0.01
190
 
191
- # 检查噪声 - AI生成图像通常噪声较低< 0.3:
 
192
  feature_score += 0.1
193
 
194
- # 检查颜色变化 - AI生成图像通常颜色变化ue_variation" in image_features and image_features["hue_variation"] < 0.1
195
- if "saturation_variation" in image_features and image_features["saturation_variation"] 0.05
196
 
197
  # 调整最终概率
198
- adjusted_probability = min(1.0, max(0.0, ai_probability + feature_score))新判断
199
  if adjusted_probability > 0.7:
200
  return "高概率AI生成", adjusted_probability
201
  elif adjusted_probability < 0.3:
@@ -278,4 +283,4 @@ iface = gr.Interface(
278
  allow_flagging="never"
279
  )
280
 
281
- 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(hsvue_variation"] = hue_std / 180 # 归一化
177
+ features["saturation_variation"] = sat_std / val_std / 255
178
+
179
+ return features
180
+
181
+ def make_final_decision(ai_probability, image_features):出更准确的决策"""
182
+ # 基础决策
183
  if ai_probability > 0.7:
184
+ base_decision = "高概率AI生成"
185
+ elif ai_probability < 0.3:
186
+ base_decision = "高概率人类创作"
187
 
 
 
188
 
189
+ # 特征调整
190
+ feature_score = 0
191
 
192
+ # 检查对称性 - 高对称性通" in image_features and image_features["horizontal_score += 0.1
193
+ if "vertical_symmetry" in image_features and image_features["vertical_symmetry"] 0.1
194
 
195
+ # 检查边缘 - AI生成图像通常边缘密度较低
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
  allow_flagging="never"
284
  )
285
 
286
+ iface.launch()