Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
from PIL import Image
|
| 4 |
+
import numpy as np
|
| 5 |
+
import os
|
| 6 |
+
from face_cropper import detect_and_label_faces
|
| 7 |
+
# Define a custom function to convert an image to grayscale
|
| 8 |
+
def to_grayscale(input_image):
|
| 9 |
+
grayscale_image = Image.fromarray(np.array(input_image).mean(axis=-1).astype(np.uint8))
|
| 10 |
+
return grayscale_image
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
description_markdown = """
|
| 14 |
+
# Fake Face Detection tool from TrustWorthy BiometraVision Lab IISER Bhopal
|
| 15 |
+
## Usage
|
| 16 |
+
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.
|
| 17 |
+
## Disclaimer
|
| 18 |
+
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.
|
| 19 |
+
## Licensing and Permissions
|
| 20 |
+
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.
|
| 21 |
+
## Developer Contact
|
| 22 |
+
For further inquiries or permissions, you can reach out to the developer through the following social media accounts:
|
| 23 |
+
- [LAB Webpage](https://sites.google.com/iiitd.ac.in/agarwalakshay/labiiserb?authuser=0)
|
| 24 |
+
- [LinkedIn](https://www.linkedin.com/in/shivam-shukla-0a50ab1a2/)
|
| 25 |
+
- [GitHub](https://github.com/SaShukla090)
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
# Create the Gradio app
|
| 32 |
+
app = gr.Interface(
|
| 33 |
+
fn=detect_and_label_faces,
|
| 34 |
+
inputs=gr.Image(type="pil"),
|
| 35 |
+
outputs="image",
|
| 36 |
+
# examples=[
|
| 37 |
+
# "path_to_example_image_1.jpg",
|
| 38 |
+
# "path_to_example_image_2.jpg"
|
| 39 |
+
# ]
|
| 40 |
+
examples=[
|
| 41 |
+
os.path.join("Examples", image_name) for image_name in os.listdir("Examples")
|
| 42 |
+
],
|
| 43 |
+
title="Fake Face Detection",
|
| 44 |
+
description=description_markdown,
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
# Run the app
|
| 48 |
+
app.launch()
|