Update api.py
Browse files
api.py
CHANGED
|
@@ -294,6 +294,7 @@ async def analyze_endpoint(
|
|
| 294 |
# A. Blur Check
|
| 295 |
gray = cv2.cvtColor(img_np, cv2.COLOR_RGB2GRAY)
|
| 296 |
blur_score = cv2.Laplacian(gray, cv2.CV_64F).var()
|
|
|
|
| 297 |
|
| 298 |
# Call Advanced Spam Check
|
| 299 |
is_spam, spam_reasons = check_spam_status(user_email, current_time, blur_score)
|
|
@@ -391,28 +392,28 @@ async def analyze_endpoint(
|
|
| 391 |
|
| 392 |
# Line 1: Identification
|
| 393 |
if primary_issue != "Unknown":
|
| 394 |
-
summary_lines.append(f"
|
| 395 |
else:
|
| 396 |
-
summary_lines.append("
|
| 397 |
|
| 398 |
# Line 2: Quality Analysis
|
| 399 |
if is_blur_spam:
|
| 400 |
-
summary_lines.append(f"
|
| 401 |
else:
|
| 402 |
-
summary_lines.append(f"
|
| 403 |
|
| 404 |
# Line 3: Assessment
|
| 405 |
-
summary_lines.append(f"
|
| 406 |
|
| 407 |
# Line 4: Status/Warnings
|
| 408 |
status_parts = []
|
| 409 |
if is_duplicate:
|
| 410 |
-
status_parts.append(f"
|
| 411 |
if is_spam:
|
| 412 |
-
status_parts.append(f"
|
| 413 |
|
| 414 |
if not status_parts:
|
| 415 |
-
status_parts.append("
|
| 416 |
|
| 417 |
summary_lines.append(" ".join(status_parts))
|
| 418 |
|
|
|
|
| 294 |
# A. Blur Check
|
| 295 |
gray = cv2.cvtColor(img_np, cv2.COLOR_RGB2GRAY)
|
| 296 |
blur_score = cv2.Laplacian(gray, cv2.CV_64F).var()
|
| 297 |
+
is_blur_spam = bool(blur_score < 100.0)
|
| 298 |
|
| 299 |
# Call Advanced Spam Check
|
| 300 |
is_spam, spam_reasons = check_spam_status(user_email, current_time, blur_score)
|
|
|
|
| 392 |
|
| 393 |
# Line 1: Identification
|
| 394 |
if primary_issue != "Unknown":
|
| 395 |
+
summary_lines.append(f"Identification: AI detected {primary_issue} with {int(max_conf*100)}% confidence.")
|
| 396 |
else:
|
| 397 |
+
summary_lines.append("Identification: No specific civic issue could be confidently identified.")
|
| 398 |
|
| 399 |
# Line 2: Quality Analysis
|
| 400 |
if is_blur_spam:
|
| 401 |
+
summary_lines.append(f"Image Quality: Poor/Blurry (Score: {int(blur_score)}/100). Please retake.")
|
| 402 |
else:
|
| 403 |
+
summary_lines.append(f"Image Quality: Good clarity (Score: {int(blur_score)}/100).")
|
| 404 |
|
| 405 |
# Line 3: Assessment
|
| 406 |
+
summary_lines.append(f"Assessment: Rated as {severity} severity, routed to {department}.")
|
| 407 |
|
| 408 |
# Line 4: Status/Warnings
|
| 409 |
status_parts = []
|
| 410 |
if is_duplicate:
|
| 411 |
+
status_parts.append(f"Duplicate: {dup_reason}.")
|
| 412 |
if is_spam:
|
| 413 |
+
status_parts.append(f"Spam Flag: {spam_reason_str}.")
|
| 414 |
|
| 415 |
if not status_parts:
|
| 416 |
+
status_parts.append("Status: Verified as a unique, valid report.")
|
| 417 |
|
| 418 |
summary_lines.append(" ".join(status_parts))
|
| 419 |
|