Skip to content

Add artwork feature extractor and fix spectral centroid bug#51

Merged
exdysa merged 3 commits intodarkshapes:mainfrom
wfproc:feature/artwork-detection
Mar 22, 2026
Merged

Add artwork feature extractor and fix spectral centroid bug#51
exdysa merged 3 commits intodarkshapes:mainfrom
wfproc:feature/artwork-detection

Conversation

@wfproc
Copy link
Copy Markdown
Contributor

@wfproc wfproc commented Mar 22, 2026

Summary

  • Fix broadcast error in fourier_discrepancy that crashed on non-square images (affected all inference on real-world images)
  • Add 49-feature CPU-only artwork extractor based on Li & Stamp (2025) "Detecting AI-generated Artwork" (arXiv:2504.07078)
  • Add benchmark tests and PDF report generator

Features added

49 image features extracted without GPU or pretrained models:

  • Brightness (2): mean, entropy
  • Color (23): RGB/HSV histogram statistics (mean, variance, kurtosis, skewness, entropy)
  • Texture (6): GLCM co-occurrence + Local Binary Patterns
  • Shape (6): HOG gradient histograms + Canny edge density
  • Noise (2): noise entropy, signal-to-noise ratio
  • Frequency (10): FFT radial band energies, spectral centroid, phase coherence, DCT analysis

Benchmark results

5-fold cross-validation on WikiArt (human) vs AI-generated images:

Model Accuracy Precision Recall
SVM (RBF) 95.0% 94.1% 96.0%
MLP 93.0% 93.0% 93.0%
XGBoost 91.0% 88.7% 94.0%
Ensemble (calibrated) 98.3% 96.7% 100.0%

Test plan

  • Existing tests pass (pytest tests/test_chip.py tests/test_dataset.py tests/test_load_spec.py)
  • Benchmark test passes (pytest tests/test_artwork_accuracy.py -v -s)
  • PDF report generates (python tests/generate_results_pdf.py)

wfproc added 3 commits March 22, 2026 21:59
The fourier_discrepancy method used log_mag.T which creates a (w,h)
matrix that can't be added to the (h,w) log_mag matrix when h != w.
Split into separate row/col contributions to avoid the broadcast.
Implements the 39-feature extraction pipeline from Li & Stamp (2025)
"Detecting AI-generated Artwork" (arXiv:2504.07078), extended with 10
FFT/DCT spectral analysis features for frequency-domain artifact detection.

Features: brightness (2), color (23), texture (6), shape (6), noise (2),
frequency (10). All CPU-only, no pretrained models required.

Includes benchmark tests with SVM/MLP/XGBoost ensemble achieving 95%+
accuracy with calibrated thresholds and abstention for uncertain images.
@exdysa exdysa merged commit ed69b49 into darkshapes:main Mar 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants