import gradio as gr import cv2 import numpy as np from modules import globals, face_analyser import os # Basic inference function def process_webcam_frame(image): if image is None: return None # Save temp image cv2_img = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR) temp_path = "input.jpg" cv2.imwrite(temp_path, cv2_img) globals.target_path = temp_path globals.source_target_map = [] try: face_analyser.get_unique_faces_from_target_image() except Exception as e: return None if globals.source_target_map and "target" in globals.source_target_map[0]: crop = globals.source_target_map[0]["target"]["cv2"] return cv2.cvtColor(crop, cv2.COLOR_BGR2RGB) return None demo = gr.Interface( fn=process_webcam_frame, inputs=gr.Image(source="webcam", label="Webcam Input", type="pil"), outputs=gr.Image(label="Processed Face", type="numpy"), title="🦉 OwlCamPro – Live Face Detection & Swap", description="Real-time face processing using Deep-Live-Cam modules. Upload or use your webcam." ) if __name__ == "__main__": demo.launch()