Spaces:
Running
Running
changed to ai-generated score
Browse files112 unmodified lines11311411511611711811939 unmodified lines1591601611621631641651661671681691701711721731741751761771781791801811821836 unmodified lines19019119219319419519619719819920020120220320420520620720820921021121221321434 unmodified lines24925025125225325425525625725825926026126226326426526626726826927027127227327460 unmodified lines3353363373383393403413423433443453463473483493503513521 unmodified line35435535635735835936036136236336436536636731 unmodified lines399400401402403404405112 unmodified lines</div><div><div id="verdict-text" class="text-3xl sm:text-4xl font-extrabold leading-tight text-blue-600"></div><div id="advice-text" class="mt-3 text-lg sm:text-xl font-semibold text-gray-900"></div><div id="frames-info" class="mt-4 text-sm text-gray-500"></div></div>39 unmodified linesclear: "Clear",analyzing: "Analyzing...",analyzing_video: "Sampling frames and running the model...",reliability_score: "Reliability score",how_calculated: "How is this calculated?",reliability: "Reliability",verdict_low_image: "This image is likely AI-generated,",verdict_low_video: "This video is likely AI-generated,",verdict_mid_image: "We're uncertain about this image,",verdict_mid_video: "We're uncertain about this video,",verdict_high_image: "This image is likely authentic,",verdict_high_video: "This video is likely authentic,",advice_low: "you should not share it with your network.",advice_mid: "verify it from trusted sources before sharing.",advice_high: "but always cross-check important content.",analyze_another: "Analyze another file",error_generic: "Something went wrong. Please try again.",error_size: "File is too large.",error_type: "Unsupported file type.",frames_info: "Averaged over {n} frames.",how_calculated_title: "How the score is computed",how_calculated_body: "We use a Swin Transformer V2 model fine-tuned to distinguish real photographs from AI-generated images. For videos, we sample 5 frames evenly across the duration and average the model's confidence. The reliability score is 1 minus the model's probability that the content is AI-generated.",close: "Close",privacy_note: "Files are processed in memory and not stored.",},6 unmodified linesclear: "Effacer",analyzing: "Analyse en cours...",analyzing_video: "Échantillonnage des images et exécution du modèle...",reliability_score: "Score de fiabilité",how_calculated: "Comment est-ce calculé ?",reliability: "Fiabilité",verdict_low_image: "Cette image est probablement générée par IA,",verdict_low_video: "Cette vidéo est probablement générée par IA,",verdict_mid_image: "Nous ne sommes pas certains pour cette image,",verdict_mid_video: "Nous ne sommes pas certains pour cette vidéo,",verdict_high_image: "Cette image est probablement authentique,",verdict_high_video: "Cette vidéo est probablement authentique,",advice_low: "vous ne devriez pas la partager avec votre réseau.",advice_mid: "vérifiez auprès de sources fiables avant de partager.",advice_high: "vérifiez tout de même les contenus importants.",analyze_another: "Analyser un autre fichier",error_generic: "Une erreur est survenue. Veuillez réessayer.",error_size: "Le fichier est trop volumineux.",error_type: "Type de fichier non pris en charge.",frames_info: "Moyenne sur {n} images.",how_calculated_title: "Comment le score est calculé",how_calculated_body: "Nous utilisons un modèle Swin Transformer V2 entraîné pour distinguer les vraies photographies des images générées par IA. Pour les vidéos, nous échantillonnons 5 images réparties uniformément sur la durée et faisons la moyenne de la confiance du modèle. Le score de fiabilité correspond à 1 moins la probabilité estimée que le contenu soit généré par IA.",close: "Fermer",privacy_note: "Les fichiers sont traités en mémoire et ne sont pas conservés.",},34 unmodified linesapplyI18n();}function getVerdict(reliability, mediaType) {const T = t();if (reliability >= 0.70) {return {verdict: mediaType === "video" ? T.verdict_high_video : T.verdict_high_image,advice: T.advice_high,tone: "high",};}if (reliability >= 0.40) {return {verdict: mediaType === "video" ? T.verdict_mid_video : T.verdict_mid_image,advice: T.advice_mid,tone: "mid",};}return {verdict: mediaType === "video" ? T.verdict_low_video : T.verdict_low_image,advice: T.advice_low,tone: "low",};}60 unmodified linesfunction renderResultText() {if (!state.result) return;const r = state.result.reliability;const v = getVerdict(r, state.result.media_type);$("verdict-text").textContent = v.verdict;$("advice-text").textContent = v.advice;$("reliability-pct").textContent = `${Math.round(r * 100)}%`;const arc = $("arc-fg");const tones = {high: "#16a34a",mid: "#d97706",low: "#1d4ed8",};arc.setAttribute("stroke", tones[v.tone]);if (state.result.media_type === "video") {$("frames-info").textContent = t().frames_info.replace("{n}", state.result.n_frames);} else {1 unmodified line}}function animateArc(reliability) {const arc = $("arc-fg");arc.style.transition = "none";arc.setAttribute("stroke-dashoffset", CIRCUMFERENCE);requestAnimationFrame(() => {requestAnimationFrame(() => {arc.style.transition = "";const target = CIRCUMFERENCE * (1 - Math.max(0, Math.min(1, reliability)));arc.setAttribute("stroke-dashoffset", target);});});31 unmodified linesstate.result = await res.json();renderResultText();showCard("result-card");animateArc(state.result.reliability);} catch (e) {showError(e.message);showCard("upload-card");112 unmodified lines11311411511611711811939 unmodified lines1591601611621631641651661671681691701711721731741751761771781791801811821836 unmodified lines19019119219319419519619719819920020120220320420520620720820921021121221321434 unmodified lines24925025125225325425525625725825926026126226326426526626726826927027127227327460 unmodified lines3353363373383393403413423433443453463473483493503513523531 unmodified line35535635735835936036136236336436536636736831 unmodified lines400401402403404405406112 unmodified lines</div><div><div id="verdict-text" class="text-3xl sm:text-4xl font-extrabold leading-tight"></div><div id="advice-text" class="mt-3 text-lg sm:text-xl font-semibold text-gray-900"></div><div id="frames-info" class="mt-4 text-sm text-gray-500"></div></div>39 unmodified linesclear: "Clear",analyzing: "Analyzing...",analyzing_video: "Sampling frames and running the model...",ai_score: "AI-generated score",how_calculated: "How is this calculated?",ai_label: "AI-generated",verdict_ai_image: "This image is likely AI-generated,",verdict_ai_video: "This video is likely AI-generated,",verdict_uncertain_image: "We're uncertain about this image,",verdict_uncertain_video: "We're uncertain about this video,",verdict_real_image: "This image is likely authentic,",verdict_real_video: "This video is likely authentic,",advice_ai: "you should not share it with your network.",advice_uncertain: "verify it from trusted sources before sharing.",advice_real: "but always cross-check important content.",analyze_another: "Analyze another file",error_generic: "Something went wrong. Please try again.",error_size: "File is too large.",error_type: "Unsupported file type.",frames_info: "Averaged over {n} frames.",how_calculated_title: "How the score is computed",how_calculated_body: "We use a Swin Transformer V2 model fine-tuned to distinguish real photographs from AI-generated images. For videos, we sample 5 frames evenly across the duration and average the model's confidence. The score shown is the model's estimated probability that the content was generated by AI.",close: "Close",privacy_note: "Files are processed in memory and not stored.",},6 unmodified linesclear: "Effacer",analyzing: "Analyse en cours...",analyzing_video: "Échantillonnage des images et exécution du modèle...",ai_score: "Score d'IA générée",how_calculated: "Comment est-ce calculé ?",ai_label: "IA générée",verdict_ai_image: "Cette image est probablement générée par IA,",verdict_ai_video: "Cette vidéo est probablement générée par IA,",verdict_uncertain_image: "Nous ne sommes pas certains pour cette image,",verdict_uncertain_video: "Nous ne sommes pas certains pour cette vidéo,",verdict_real_image: "Cette image est probablement authentique,",verdict_real_video: "Cette vidéo est probablement authentique,",advice_ai: "vous ne devriez pas la partager avec votre réseau.",advice_uncertain: "vérifiez auprès de sources fiables avant de partager.",advice_real: "vérifiez tout de même les contenus importants.",analyze_another: "Analyser un autre fichier",error_generic: "Une erreur est survenue. Veuillez réessayer.",error_size: "Le fichier est trop volumineux.",error_type: "Type de fichier non pris en charge.",frames_info: "Moyenne sur {n} images.",how_calculated_title: "Comment le score est calculé",how_calculated_body: "Nous utilisons un modèle Swin Transformer V2 entraîné pour distinguer les vraies photographies des images générées par IA. Pour les vidéos, nous échantillonnons 5 images réparties uniformément sur la durée et faisons la moyenne de la confiance du modèle. Le score affiché correspond à la probabilité estimée que le contenu ait été généré par IA.",close: "Fermer",privacy_note: "Les fichiers sont traités en mémoire et ne sont pas conservés.",},34 unmodified linesapplyI18n();}function getVerdict(aiScore, mediaType) {const T = t();if (aiScore >= 0.60) {return {verdict: mediaType === "video" ? T.verdict_ai_video : T.verdict_ai_image,advice: T.advice_ai,tone: "ai",};}if (aiScore >= 0.30) {return {verdict: mediaType === "video" ? T.verdict_uncertain_video : T.verdict_uncertain_image,advice: T.advice_uncertain,tone: "uncertain",};}return {verdict: mediaType === "video" ? T.verdict_real_video : T.verdict_real_image,advice: T.advice_real,tone: "real",};}60 unmodified linesfunction renderResultText() {if (!state.result) return;const score = state.result.p_fake;const v = getVerdict(score, state.result.media_type);$("verdict-text").textContent = v.verdict;$("advice-text").textContent = v.advice;$("score-pct").textContent = `${Math.round(score * 100)}%`;const tones = {ai: "#dc2626",uncertain: "#d97706",real: "#16a34a",};const color = tones[v.tone];$("arc-fg").setAttribute("stroke", color);$("verdict-text").style.color = color;if (state.result.media_type === "video") {$("frames-info").textContent = t().frames_info.replace("{n}", state.result.n_frames);} else {1 unmodified line}}function animateArc(fraction) {const arc = $("arc-fg");arc.style.transition = "none";arc.setAttribute("stroke-dashoffset", CIRCUMFERENCE);requestAnimationFrame(() => {requestAnimationFrame(() => {arc.style.transition = "";const target = CIRCUMFERENCE * (1 - Math.max(0, Math.min(1, fraction)));arc.setAttribute("stroke-dashoffset", target);});});31 unmodified linesstate.result = await res.json();renderResultText();showCard("result-card");animateArc(state.result.p_fake);} catch (e) {showError(e.message);showCard("upload-card");
app/static/index.html+49-48