Spaces:
Running
Running
Upload index-1.html
Browse files- index-1.html +87 -0
index-1.html
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
+
<title>AI Image Detector</title>
|
| 7 |
+
<style>
|
| 8 |
+
body{margin:0;font:16px/1.5 system-ui,sans-serif;background:#0f151b;color:#e8eef3}
|
| 9 |
+
main{max-width:520px;margin:0 auto;padding:24px 16px}
|
| 10 |
+
h1{font-size:28px;margin:8px 0}
|
| 11 |
+
p{color:#93a3b1}
|
| 12 |
+
input{display:block;width:100%;margin:16px 0;padding:14px;background:#18212a;border:2px dashed #2c3844;border-radius:12px;color:#e8eef3}
|
| 13 |
+
img{max-width:100%;border-radius:10px;margin-top:8px}
|
| 14 |
+
#res{background:#18212a;border-radius:12px;padding:16px;margin-top:16px;display:none}
|
| 15 |
+
h2{margin:0 0 6px}
|
| 16 |
+
.bar{height:12px;background:#2c3844;border-radius:6px;overflow:hidden;margin:8px 0}
|
| 17 |
+
.bar div{height:100%;background:#6f93ff;width:0}
|
| 18 |
+
li{color:#f0b04a;margin:4px 0}
|
| 19 |
+
small{color:#93a3b1}
|
| 20 |
+
</style>
|
| 21 |
+
</head>
|
| 22 |
+
<body>
|
| 23 |
+
<main>
|
| 24 |
+
<h1>Was this image made by AI?</h1>
|
| 25 |
+
<p>Runs on your phone. Your image is never uploaded. The first check downloads the model (about 100 to 400 MB), so use Wi-Fi.</p>
|
| 26 |
+
<input id="f" type="file" accept="image/*">
|
| 27 |
+
<img id="p" alt="">
|
| 28 |
+
<div id="res">
|
| 29 |
+
<h2 id="v"></h2>
|
| 30 |
+
<div id="pct"></div>
|
| 31 |
+
<div class="bar"><div id="b"></div></div>
|
| 32 |
+
<ul id="m"></ul>
|
| 33 |
+
<small id="raw"></small><br>
|
| 34 |
+
<small>A probability, not proof. Detectors can be wrong, especially on new generators and screenshots.</small>
|
| 35 |
+
</div>
|
| 36 |
+
</main>
|
| 37 |
+
<script type="module">
|
| 38 |
+
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3';
|
| 39 |
+
const $ = id => document.getElementById(id);
|
| 40 |
+
const MODEL = 'onnx-community/CommunityForensics-DeepfakeDet-ViT-ONNX';
|
| 41 |
+
let clf;
|
| 42 |
+
async function load(){
|
| 43 |
+
if(clf) return clf;
|
| 44 |
+
try { clf = await pipeline('image-classification', MODEL, { dtype: 'q8' }); }
|
| 45 |
+
catch(e){ clf = await pipeline('image-classification', MODEL); }
|
| 46 |
+
return clf;
|
| 47 |
+
}
|
| 48 |
+
const TOOLS = [[/midjourney/i,'Midjourney'],[/dall[\s\-·]?e|openai/i,'OpenAI / DALL·E'],[/stable\s?diffusion|sdxl|automatic1111/i,'Stable Diffusion'],[/firefly|generative ?fill/i,'Adobe Firefly'],[/imagen|gemini|synthid/i,'Google AI'],[/leonardo\.?ai/i,'Leonardo AI'],[/comfyui/i,'ComfyUI'],[/ideogram/i,'Ideogram']];
|
| 49 |
+
function markers(bytes){
|
| 50 |
+
const t = new TextDecoder('latin1').decode(bytes), out = [];
|
| 51 |
+
if(/c2pa|jumbf|contentcredentials/i.test(t)) out.push('Content Credentials (C2PA) found');
|
| 52 |
+
if(/algorithmicMedia/.test(t)) out.push('Marked as AI media in metadata');
|
| 53 |
+
TOOLS.forEach(([re,n]) => { if(re.test(t)) out.push('Names an AI tool: ' + n); });
|
| 54 |
+
if(/Steps:\s*\d+,\s*Sampler|negative prompt|"class_type"/i.test(t)) out.push('Contains a generation prompt or settings');
|
| 55 |
+
return out;
|
| 56 |
+
}
|
| 57 |
+
$('f').onchange = async e => {
|
| 58 |
+
const file = e.target.files[0]; if(!file) return;
|
| 59 |
+
const url = URL.createObjectURL(file);
|
| 60 |
+
$('p').src = url;
|
| 61 |
+
$('res').style.display = 'block';
|
| 62 |
+
$('v').textContent = 'Loading model, please wait...';
|
| 63 |
+
$('pct').textContent = ''; $('b').style.width = '0'; $('m').innerHTML = ''; $('raw').textContent = '';
|
| 64 |
+
try {
|
| 65 |
+
const mk = markers(new Uint8Array(await file.arrayBuffer()));
|
| 66 |
+
const c = await load();
|
| 67 |
+
$('v').textContent = 'Checking...';
|
| 68 |
+
const r = await c(url, { top_k: 5 });
|
| 69 |
+
const hit = r.find(x => /fake|ai|synth|generat|artificial/i.test(x.label));
|
| 70 |
+
let ai = hit ? hit.score : null;
|
| 71 |
+
if(ai === null && r.length === 2){ ai = r[0].score < 0.5 ? r[0].score : 1 - r[1].score; }
|
| 72 |
+
$('raw').textContent = 'Model output: ' + r.map(x => x.label + ' ' + Math.round(x.score*100) + '%').join(', ');
|
| 73 |
+
mk.forEach(t => { const li = document.createElement('li'); li.textContent = t; $('m').appendChild(li); });
|
| 74 |
+
if(mk.length) $('v').textContent = 'AI markers found';
|
| 75 |
+
else if(ai === null) $('v').textContent = 'Result below';
|
| 76 |
+
else if(ai >= 0.85) $('v').textContent = 'Likely AI-generated';
|
| 77 |
+
else if(ai >= 0.5) $('v').textContent = 'Possibly AI';
|
| 78 |
+
else $('v').textContent = 'Likely a real photo';
|
| 79 |
+
if(ai !== null){ $('pct').textContent = 'Chance it is AI: ' + Math.round(ai*100) + '%'; $('b').style.width = Math.round(ai*100) + '%'; }
|
| 80 |
+
} catch(err){
|
| 81 |
+
$('v').textContent = 'Could not analyze this image.';
|
| 82 |
+
$('raw').textContent = String(err);
|
| 83 |
+
}
|
| 84 |
+
};
|
| 85 |
+
</script>
|
| 86 |
+
</body>
|
| 87 |
+
</html>
|