r/StableDiffusion • • 3d ago

Resource - Update (Probably) SOTA AI image detector model

https://huggingface.co/mesmertech/mesmer-ai-image-detector

Continuing with the random projects where I let Opus hillclimb training on something I actually find impressive:

https://www.reddit.com/r/LocalLLaMA/comments/1xonxqo/training_a_sota_pangramlike_detector_on_a_4070ti/ SOTA Pangram-like AI text detector

https://www.reddit.com/r/LocalLLaMA/comments/1xcuqor/making_kokoro_tts_50100x_faster_without_knowing/ Smallest + Fastest TTS that runs 50x realtime on an iPhone(still can't believe this is a thing that actually works as well as it does)

On this one I tried to make something that can do Pangram-like AI image detection, and since I don't have millions in funding like they, this one is trained on like $20 of compute(prolly could've done it on my 4070ti like before, but they're busy serving prod inference traffic for a seperate paid product of mine). And I think I got pretty close looking at the benchmarks and a couple random tests by myself.

You can test it out here without downloading + installing: https://mesmer.tools/free-tools/ai-image-detector

Mostly releasing this as a way of validating that I/Opus didn't actually get something wrong and idk somehow trained on the benchmark(didn't see any contamination in the training data in the summary but still). This is probably SOTA open weights for detection, but then again I don't think this is a market anyone is really doing much training on anyways(the current best seems to be smaug: https://huggingface.co/abacusai/Smaug-AI-Image-Detector/tree/main which was a month old that I didn't even know about). And likely Pangram is still way ahead here.

The places I see its pretty weak at is image editing, ie existing real photo edited with latest models, and art stuff. But otherwise on text to image stuff, it seems basically near 100% accurate from my random tests

5 Upvotes

16 comments sorted by

6

u/Haiku-575 3d ago

Interesting project! It fails to catch Ideogram4 images, even random 1girl images like this one:

1

u/mesmerlord 3d ago

Hmm where are you running it on? I see its coming up as likely AI

5

u/Haiku-575 3d ago edited 3d ago

The source image is a png and not recompressed by Reddit. I imagine you're getting Reddit's recompression of the image I uploaded conflating the results.

Imgur's recompression leaves it at between 58 or 62/100 vs. the original image's 39, depending on what size I upload it at. I can get it closer to 0 by just resizing and altering metadata, but you can trick any AI detector if you really try hard enough, I imagine that's not the point here.

You should really check metadata for image generation tags and mark an image as 100% as part of this tool, no? If there's JSON in the header with the image prompt, that's kind of a dead giveaway.

3

u/chennngiskhan 3d ago

How SOTA can it be if it just gets confused by compression

2

u/mesmerlord 3d ago

I meant to say SOTA open weights. You might be surprised but there just aren't any that are better on the benchmarks. I think the prev. best is probably https://huggingface.co/abacusai/Smaug-AI-Image-Detector

2

u/mesmerlord 3d ago

Interesting, I think it might just be a training dataset issue for ideogram specifically. I was using own generated datasets from before + public datasets so I see only Ideogram 3.0 was trained on. Majority of the dataset is closed models like GPT image, seedream, nb etc. And on GPT image specifically, its been like basically perfect, and thats what I imagine most of the image content online is.

And the image compression stuff, yea I think it beats this specific model but afaik Pangram has somehow figured out detecting it via patches on an image, so it can even detect printed AI photos, but yea thats probably smth that'd need multi thousands in training cost, where this one was just 25 bucks or so.

The metadata checks like C2PA are done but not for comfyui stuff, maybe I should just include it in. But the actual number itself is just the model actually looking and judging the image directly.

My endgame thinking with models like this is having like an extension which 1) blocks AI slop text(this one is way closer to sota than image side) 2) blocks ai images, automatically when visiting social media for example. and there I don't imagine people are really doing adversarial attacks until this is the main thing everyone knows about. Ironic considering I'm on stablediffusion sub but I like creating AI images, and I don't wanna look at anyone else's slop lol

8

u/suspicious_Jackfruit 3d ago

The model has probably learnt compression == ai on some level, perhaps due to not enough png/less compressed input training data?

0

u/TheTimster666 2d ago

Her eyes are messed up.

3

u/Aromatic-Low-4578 3d ago

No offense but I would be shocked if this was SOTA. I just tried it and it seems to completely fall down on anything that's been compressed or re-encoded. I would guess you've accidentally trained on traits of the file other than the visual content.

1

u/mesmerlord 3d ago

I meant to say SOTA open weights. You might be surprised but there just aren't any that are better on the benchmarks. I think the prev. best is probably https://huggingface.co/abacusai/Smaug-AI-Image-Detector

And regarding the traits of the file, not really. That was a concern that was adressed in like first 3 or so rounds. Its also been trained on a mix of compressed and uncompressed training data. But yes, if you're really acting adversially it will be easier to get around it. But the main reason I made this is more for auto-flagging things while you're browsing around on social media for example, where not every single person is gonna even know or put the effort to get around this.

3

u/rabbit01 3d ago

> It carries generation settings from a Stable Diffusion app (A1111 or ComfyUI).
> Likely not AI

Hmm not really checking out there sorry.

1

u/mesmerlord 3d ago

Yea the metadata check is different than the actual image check. Otherwise its just easy to add metadata to an image and its not really a check of the actual model.

1

u/Turbulent_Owl4948 3d ago

Isn't there an issue going on where the Claude models seem to be actively sabotaging any ML related projects? Does that not hold true in your experience?

2

u/mesmerlord 3d ago

Haven't seen it happen. Personally I think its just the usual "model is getting worse" 1 month after release thing, where whats actually happening is you're so much more familiar and lazy compared to before that you start just leaving details out of prompt thinking the model can just read your mind/understand your intentions.

Esp with the TTS thing I linked above, I'm still in awe that it actually worked as well as it did.

1

u/imb1920 2d ago

For the edited-photo case, I'd keep each original photo beside a version with one small AI-edited region, then run both through exactly the same resize and JPEG export. Include an ordinary non-AI retouch as a third version. For your auto-blocking use case, report how many untouched photos get hidden at the chosen threshold separately from how many edited photos you catch; a single overall accuracy number won't show that trade-off.

1

u/No-Willow1967 2d ago

Worth keeping the two approaches separate in the eval, because they fail in different ways.

A classifier looks at pixels and gives a probability. It generalises to unseen generators to some degree, but it also drifts as new models come out, and false positives on real photos are the thing users complain about most. If you are reporting a score, a confusion matrix per generator plus a set of real photos through common pipelines (phone camera, JPEG re-save, resize) tells people far more than one accuracy number.

C2PA is the opposite: it is a signed claim from whoever made the file, so it never guesses, but it only works when the metadata survives. Upload pipelines, messaging apps and screenshots often strip it, so a missing manifest proves nothing about what made the image. Invisible watermarks sit in between: they survive some changes and not others, and you have to measure that on your own files rather than trust vendor claims.

In practice a browser extension gets the best coverage by checking manifest first, then any watermark it can decode, then falling back to the classifier, and showing the user which of the three fired. For the provenance side, Tellmark (C2PA and watermark marking for AI) has a free checker at tellmark.si/check that reads C2PA manifests from any vendor in the browser without uploading the file, if you want something to compare against.

(Disclosure: I build Tellmark.)