import gradio as gr from PIL import Image import numpy as np import os from face_cropper import detect_and_label_faces # Define a custom function to convert an image to grayscale def to_grayscale(input_image): grayscale_image = Image.fromarray(np.array(input_image).mean(axis=-1).astype(np.uint8)) return grayscale_image description_markdown = """ # Fake Face Detection tool from TrustWorthy BiometraVision Lab IISER Bhopal ## Usage This tool expects a face image as input. Upon submission, it will process the image and provide an output with bounding boxes drawn on the face. Alongside the visual markers, the tool will give a detection result indicating whether the face is fake or real. ## Disclaimer Please note that this tool is for research purposes only and may not always be 100% accurate. Users are advised to exercise discretion and supervise the tool's usage accordingly. ## Licensing and Permissions This tool has been developed solely for research and demonstrative purposes. Any commercial utilization of this tool is strictly prohibited unless explicit permission has been obtained from the developers. ## Developer Contact For further inquiries or permissions, you can reach out to the developer through the following social media accounts: - [LAB Webpage](https://sites.google.com/iiitd.ac.in/agarwalakshay/labiiserb?authuser=0) - [LinkedIn](https://www.linkedin.com/in/shivam-shukla-0a50ab1a2/) - [GitHub](https://github.com/SaShukla090) """ # Create the Gradio app app = gr.Interface( fn=detect_and_label_faces, inputs=gr.Image(type="pil"), outputs="image", # examples=[ # "path_to_example_image_1.jpg", # "path_to_example_image_2.jpg" # ] examples=[ os.path.join("Examples", image_name) for image_name in os.listdir("Examples") ], title="Fake Face Detection", description=description_markdown, ) # Run the app app.launch()