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.")