import gradio as gr import numpy as np import time def process_image(img): """Placeholder function - replace with your backend integration""" if img is None: return "No image provided", "", "" time.sleep(1) # Simulate processing return "Processing Complete", "Real Face", "Confidence: 95%" with gr.Blocks() as demo: gr.Markdown("# Face Spoofing Detection System") with gr.Tabs(): with gr.Tab("Webcam Detection"): webcam = gr.Image(label="Webcam Feed") webcam_status = gr.Textbox(label="Status", value="Ready") webcam_result = gr.Textbox(label="Detection Result") webcam_conf = gr.Textbox(label="Confidence Score") webcam_button = gr.Button("Analyze") webcam_button.click( fn=process_image, inputs=webcam, outputs=[webcam_status, webcam_result, webcam_conf] ) with gr.Tab("Image Upload"): image_input = gr.Image(label="Upload Image") image_status = gr.Textbox(label="Status", value="Ready") image_result = gr.Textbox(label="Detection Result") image_conf = gr.Textbox(label="Confidence Score") image_button = gr.Button("Analyze") image_button.click( fn=process_image, inputs=image_input, outputs=[image_status, image_result, image_conf] ) gr.Markdown(""" ### Instructions: 1. Choose either Webcam or Image Upload tab 2. For webcam: Allow camera access and take a photo 3. For images: Upload an image from your device 4. Click Analyze to process the image """) if __name__ == "__main__": demo.launch()