File size: 2,450 Bytes
0325f9e
cec068d
 
36c65ef
 
cec068d
36c65ef
0325f9e
cec068d
 
 
0325f9e
36c65ef
 
 
 
 
 
 
 
0325f9e
36c65ef
 
 
 
 
 
 
 
cec068d
 
 
 
 
 
36c65ef
cec068d
 
36c65ef
 
cec068d
36c65ef
 
cec068d
 
36c65ef
 
 
cec068d
 
 
 
 
 
 
36c65ef
cec068d
 
 
 
 
 
 
 
 
 
 
 
 
 
36c65ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import streamlit as st
import numpy as np
from PIL import Image
import insightface
import cv2
import os
import tempfile

st.set_page_config(page_title="Face Finder on Internet", layout="centered")
st.title("🕵️‍♂️ Check if Your Face Exists on the Internet")
st.markdown("Upload your photo and we'll search for public matches using reverse image search and AI-based face comparison.")

# Load InsightFace model
@st.cache_resource
def load_model():
    model = insightface.app.FaceAnalysis(name='buffalo_l')
    model.prepare(ctx_id=0)
    return model

model = load_model()

# Function to extract face embeddings
def get_face_embedding(image):
    image = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR)
    faces = model.get(image)
    if faces:
        return faces[0].embedding
    else:
        return None

# UI: Upload image
uploaded_file = st.file_uploader("Upload your face image (jpg/png)", type=["jpg", "jpeg", "png"])

if uploaded_file:
    # Show uploaded image
    image = Image.open(uploaded_file).convert("RGB")
    st.image(image, caption="Uploaded Image", use_column_width=True)

    # Extract face embedding
    embedding = get_face_embedding(image)

    if embedding is not None:
        st.success("Face features extracted successfully ✅")

        # Convert image to bytes for reverse search
        img_byte_arr = tempfile.NamedTemporaryFile(delete=False, suffix=".jpg")
        image.save(img_byte_arr.name)
        img_bytes = open(img_byte_arr.name, 'rb').read()

        # Provide links for manual reverse search
        st.subheader("🔍 Search Your Face on the Web")
        col1, col2, col3 = st.columns(3)

        with col1:
            st.markdown("[Search on Google](https://images.google.com)")
            st.caption("Upload the same image manually")

        with col2:
            st.markdown("[Search on Yandex](https://yandex.com/images)")
            st.caption("Yandex is great for face search")

        with col3:
            st.markdown("[Search on Bing](https://www.bing.com/visualsearch)")
            st.caption("Another good reverse image search")

        st.info("These tools let you check if your face appears on the internet. Full automation is limited due to privacy restrictions.")
    else:
        st.warning("No face detected in the uploaded image. Try another photo.")

st.markdown("---")
st.markdown("Created with ❤️ using open-source InsightFace and public search tools.")