Coherence Detection

Model Description

A ResNet-34 fine-tuned on a personally-curated dataset to classify images into one of three categories:

  • Coherent
  • Incoherent
  • Semi-Incoherent

Key Feature: This model includes a production-ready loading wrapper that handles FastAI's AdaptiveConcatPool2d and safe/unsafe weight loading.

Installation and Usage

Important: This model requires custom loading code due to FastAI architecture.

  1. Install
# First install PyTorch with the correct CUDA version for your system
# Visit https://pytorch.org/get-started/locally/ for the right command

# Example for CUDA 11.8:
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118

# Example for CPU-only:
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu

# Once torch is installed and verified:
pip install -r requirements.txt
  1. Download and run the example:
python example_usage.py
  1. Use in your code:
from example_usage import CoherenceClassifier
# Initialize with your model
classifier = CoherenceClassifier("coherence_model.pth")
# Predict on an image
result = classifier.predict("your_image.jpg", return_probs=True)
print(result)  # {'coherent': 0.85, 'incoherent': 0.05, 'semi-incoherent': 0.10}

Note on weights_only=False: This model contains FastAI's AdaptiveConcatPool2d layer. You must either:

  • Use weights_only=False (only if you trust the source), OR
  • Register AdaptiveConcatPool2d in __main__ before loading (see example_usage.py).

Model Architecture

Backbone: ResNet-34 (via FastAI's default) Pooling: AdaptiveConcatPool2d (FastAI-specific) Input size: 224x224 (standard ImageNet normalization)

Training Data

For version 1.0, a small dataset was used of ~20k images in coherent category, and ~ 12k images in both incoherent and semi-incoherent categories. Access to dataset will not be made available. An attempt was made to include a wide range of content in the coherent category to avoid false positive incoherency results.

Limitations

  • PyTorch environment
  • weights_only=False loading has security implications; use only with trusted models.

Note especially that while an attempt was made at classifying the less obvious but definitely noticeable generation failures like the following into the "semi-incoherent" category, these are much harder to detect and in the current iteration of this model there is no expectation that they will be observed in any particular coherence category, especially when these particular errors occur in a small part of the image.

  • Extra or missing limbs, fingers, or facial features
  • Disproportionate body, head, or limbs
  • Anatomically implausible joint configurations

Intended Use

This model is intended only for evaluating the coherence of AI-generated images.

  • Do not use it to classify or moderate real photographs, as it may produce nonsensical and harmful misclassifications.
  • A "semi-incoherent" or "incoherent" result should be a flag for human review, not necessarily an automatic basis for censorship.

Comment

Given the low coherence rate of results produced by early image generation models, it was very surprising that a model was not found for this purpose, necessitating the creation of this one for high-volume review scenarios.

Perhaps models such as this one are avoided or seen as improper due to the perceived danger they pose in introduction of bias to image analysis, however it is highly likely that image generators would rather have at least some bias towards coherence and a somewhat clear mind when reviewing their image output than no bias and a mind littered with the psychologically damaging results of obviously-failed generations which have little to do with the prompter's intent.

Model Card Authors

Tom Hall

Model Card Contact

tomhall.main@gmail.com

Model Card Version

Version: 1.0 | See all versions

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support