Spaces:
Running
Running
Commit ·
b39683a
1
Parent(s): 2386116
fix(cleanup): final pyflakes cleanup across 4 files
Browse filesimage_type_classifier.py: remove unused arr_hsv, hsv_img, colorsys import
report_exporter.py: remove unused struct, datetime; fix dead y variable
and add() function; fix bare f-string buf.write(f'0 6\n')
batch_processor.py: remove unused hashlib, BytesIO imports
analyze.py: remove unused 'import time as _time' inside metrics recorder
backend/api/routes/analyze.py
CHANGED
|
@@ -170,7 +170,6 @@ async def analyze_image(
|
|
| 170 |
|
| 171 |
# Record metrics
|
| 172 |
try:
|
| 173 |
-
import time as _time
|
| 174 |
record_analysis(
|
| 175 |
ai_probability=report["summary"]["ai_probability"],
|
| 176 |
classification=report["summary"]["ai_classification"],
|
|
|
|
| 170 |
|
| 171 |
# Record metrics
|
| 172 |
try:
|
|
|
|
| 173 |
record_analysis(
|
| 174 |
ai_probability=report["summary"]["ai_probability"],
|
| 175 |
classification=report["summary"]["ai_classification"],
|
backend/services/batch_processor.py
CHANGED
|
@@ -17,9 +17,7 @@ Limits:
|
|
| 17 |
Processing is sequential to avoid OOM on GPU
|
| 18 |
"""
|
| 19 |
import logging
|
| 20 |
-
import hashlib
|
| 21 |
from typing import Dict, Any, List
|
| 22 |
-
from io import BytesIO
|
| 23 |
|
| 24 |
logger = logging.getLogger(__name__)
|
| 25 |
|
|
@@ -230,4 +228,4 @@ def process_batch(
|
|
| 230 |
"duplicate_pairs": _find_duplicates(reports),
|
| 231 |
"provenance_consistency": _provenance_consistency(reports),
|
| 232 |
"individual_reports": results,
|
| 233 |
-
}
|
|
|
|
| 17 |
Processing is sequential to avoid OOM on GPU
|
| 18 |
"""
|
| 19 |
import logging
|
|
|
|
| 20 |
from typing import Dict, Any, List
|
|
|
|
| 21 |
|
| 22 |
logger = logging.getLogger(__name__)
|
| 23 |
|
|
|
|
| 228 |
"duplicate_pairs": _find_duplicates(reports),
|
| 229 |
"provenance_consistency": _provenance_consistency(reports),
|
| 230 |
"individual_reports": results,
|
| 231 |
+
}
|
backend/services/image_type_classifier.py
CHANGED
|
@@ -63,10 +63,7 @@ def classify_image_type(image_bytes: bytes, filename: str = "unknown") -> Dict[s
|
|
| 63 |
edge_density = float(np.count_nonzero(edges) / max(edges.size, 1))
|
| 64 |
|
| 65 |
# 3. Color saturation
|
| 66 |
-
arr_hsv = np.array(img.convert("HSV") if hasattr(img, 'convert') else img)
|
| 67 |
try:
|
| 68 |
-
hsv_img = img.copy()
|
| 69 |
-
import colorsys
|
| 70 |
rgb_flat = arr.reshape(-1, 3) / 255.0
|
| 71 |
# Approximate saturation from RGB
|
| 72 |
r, g, b = rgb_flat[:, 0], rgb_flat[:, 1], rgb_flat[:, 2]
|
|
|
|
| 63 |
edge_density = float(np.count_nonzero(edges) / max(edges.size, 1))
|
| 64 |
|
| 65 |
# 3. Color saturation
|
|
|
|
| 66 |
try:
|
|
|
|
|
|
|
| 67 |
rgb_flat = arr.reshape(-1, 3) / 255.0
|
| 68 |
# Approximate saturation from RGB
|
| 69 |
r, g, b = rgb_flat[:, 0], rgb_flat[:, 1], rgb_flat[:, 2]
|
backend/services/report_exporter.py
CHANGED
|
@@ -27,9 +27,7 @@ import json
|
|
| 27 |
import csv
|
| 28 |
import io
|
| 29 |
import logging
|
| 30 |
-
import struct
|
| 31 |
import zlib
|
| 32 |
-
from datetime import datetime
|
| 33 |
from typing import Dict, Any
|
| 34 |
|
| 35 |
logger = logging.getLogger(__name__)
|
|
@@ -160,13 +158,7 @@ class _PDFWriter:
|
|
| 160 |
platform_o = platform.get("predicted_platform", "N/A")
|
| 161 |
c2pa_status = c2pa.get("provenance_status", "N/A")
|
| 162 |
|
| 163 |
-
# Build page 1 content
|
| 164 |
-
lines = []
|
| 165 |
-
y = 750
|
| 166 |
-
def add(text, x=50, bold=False):
|
| 167 |
-
lines.append((0, 0, "")) # placeholder — we'll use Td chaining below
|
| 168 |
-
|
| 169 |
-
# We'll build a flat text stream manually
|
| 170 |
text_ops = []
|
| 171 |
text_ops.append(b"BT")
|
| 172 |
text_ops.append(b"/F1 16 Tf")
|
|
@@ -279,7 +271,7 @@ class _PDFWriter:
|
|
| 279 |
|
| 280 |
xref_offset = buf.tell()
|
| 281 |
buf.write(b"xref\n")
|
| 282 |
-
buf.write(
|
| 283 |
buf.write(b"0000000000 65535 f \n")
|
| 284 |
for i in range(1, 6):
|
| 285 |
buf.write(f"{offsets[i]:010d} 00000 n \n".encode())
|
|
|
|
| 27 |
import csv
|
| 28 |
import io
|
| 29 |
import logging
|
|
|
|
| 30 |
import zlib
|
|
|
|
| 31 |
from typing import Dict, Any
|
| 32 |
|
| 33 |
logger = logging.getLogger(__name__)
|
|
|
|
| 158 |
platform_o = platform.get("predicted_platform", "N/A")
|
| 159 |
c2pa_status = c2pa.get("provenance_status", "N/A")
|
| 160 |
|
| 161 |
+
# Build page 1 content stream
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
text_ops = []
|
| 163 |
text_ops.append(b"BT")
|
| 164 |
text_ops.append(b"/F1 16 Tf")
|
|
|
|
| 271 |
|
| 272 |
xref_offset = buf.tell()
|
| 273 |
buf.write(b"xref\n")
|
| 274 |
+
buf.write(b"0 6\n")
|
| 275 |
buf.write(b"0000000000 65535 f \n")
|
| 276 |
for i in range(1, 6):
|
| 277 |
buf.write(f"{offsets[i]:010d} 00000 n \n".encode())
|