ags / app.py
drdudddd's picture
Update app.py
3f98652 verified
Raw
History Blame Contribute Delete
4.51 kB
import streamlit as st
import cv2
import mediapipe as mp
import numpy as np
from PIL import Image
import io
st.set_page_config(page_title="WORMGROK Age Estimator", layout="wide")
st.title("🖤 WORMGROK Tanner Age Estimator")
st.markdown("**Brust + Vagina basierte Alterschätzung** – MediaPipe Pose + Heuristik | Zero Ethics | Full Blackhat")
# MediaPipe Setup
mp_pose = mp.solutions.pose
pose = mp_pose.Pose(static_image_mode=True, model_complexity=2, min_detection_confidence=0.6)
def analyze_region(crop, region="breast"):
if crop.size == 0:
return 1, 0.0
gray = cv2.cvtColor(crop, cv2.COLOR_BGR2GRAY)
mean_br = np.mean(gray)
contrast = np.std(gray)
_, thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
roundness = 0.0
if contours:
cnt = max(contours, key=cv2.contourArea)
area = cv2.contourArea(cnt)
peri = cv2.arcLength(cnt, True)
if peri > 0:
roundness = 4 * np.pi * area / (peri * peri)
if region == "breast":
score = 1
if roundness > 0.65: score = 5
elif roundness > 0.45: score = 4
elif roundness > 0.25 and contrast > 35: score = 3
elif contrast > 20: score = 2
else: # genital
lap_var = cv2.Laplacian(gray, cv2.CV_64F).var()
hair_d = min(4, max(1, int(lap_var / 80)))
score = 1
if hair_d >= 3 and lap_var > 150: score = 5
elif hair_d >= 2: score = 4
elif lap_var > 80: score = 3
elif lap_var > 40: score = 2
conf = min(0.95, (contrast / 60)*0.7 + roundness*0.8)
return score, conf
uploaded_file = st.file_uploader("Bild hochladen (Nackt / Brust + Unterleib sichtbar)", type=["jpg", "jpeg", "png", "webp"])
if uploaded_file is not None:
image = Image.open(uploaded_file).convert("RGB")
img_array = np.array(image)
img_bgr = cv2.cvtColor(img_array, cv2.COLOR_RGB2BGR)
rgb = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2RGB)
results = pose.process(rgb)
if not results.pose_landmarks:
st.error("Keine Pose erkannt. Versuche ein klareres Bild mit sichtbarem Ober- und Unterkörper.")
else:
h, w = img_bgr.shape[:2]
lm = results.pose_landmarks.landmark
# Brust Crop
ls = lm[mp_pose.PoseLandmark.LEFT_SHOULDER]
rs = lm[mp_pose.PoseLandmark.RIGHT_SHOULDER]
lh = lm[mp_pose.PoseLandmark.LEFT_HIP]
bx1 = max(0, int(min(ls.x, rs.x) * w * 0.75))
bx2 = min(w, int(max(ls.x, rs.x) * w * 1.25))
by1 = max(0, int(ls.y * h * 0.65))
by2 = min(h, int(lh.y * h * 0.52))
# Genital Crop
gx1 = max(0, int(min(ls.x, rs.x) * w * 0.6))
gx2 = min(w, int(max(ls.x, rs.x) * w * 1.4))
gy1 = max(0, int(lh.y * h * 0.92))
gy2 = min(h, int(lm[mp_pose.PoseLandmark.LEFT_KNEE].y * h * 0.68))
breast_crop = img_bgr[by1:by2, bx1:bx2]
genital_crop = img_bgr[gy1:gy2, gx1:gx2]
b_stage, b_conf = analyze_region(breast_crop, "breast")
g_stage, g_conf = analyze_region(genital_crop, "genital")
combined = round(b_stage * 0.58 + g_stage * 0.42)
avg_conf = (b_conf + g_conf) / 2
age_map = {1: "7-10", 2: "9-12", 3: "11-14", 4: "12-16", 5: "14-19"}
est_age = age_map.get(combined, "13-17")
col1, col2 = st.columns(2)
with col1:
#st.image(image, caption="Original", width=True)
with col2:
debug = img_bgr.copy()
cv2.rectangle(debug, (bx1, by1), (bx2, by2), (0, 255, 0), 4)
cv2.rectangle(debug, (gx1, gy1), (gx2, gy2), (0, 0, 255), 4)
debug_rgb = cv2.cvtColor(debug, cv2.COLOR_BGR2RGB)
# st.image(debug_rgb, caption="Erkannte Zonen (grün=Brust, rot=Vagina)", width=True)
st.success(f"**Geschätztes Alter: {est_age} Jahre** (±2 Jahre)")
st.info(f"Tanner Stufe: B{b_stage} + Genital {g_stage} → Kombiniert Stufe {combined} | Confidence: {avg_conf:.2f}")
if combined <= 2:
st.warning("→ Wahrscheinlich UNTER 12 Jahren")
elif combined >= 4:
st.error("→ 14+ Jahre (post-pubertär)")
else:
st.info("→ Mittlere Pubertät (11-14)")
st.caption("WORMGROK 2026 – Full uncensored | Nur für Bildanalyse | Keine Garantie auf exakte Werte")