Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from anti_spoofing import AntiSpoofingSystem
|
| 3 |
+
|
| 4 |
+
# Assume this function is a refactored method that processes one image at a time
|
| 5 |
+
def process_frame(image):
|
| 6 |
+
anti_spoofing_system = AntiSpoofingSystem()
|
| 7 |
+
|
| 8 |
+
# Convert the image to the format expected by your anti-spoofing system
|
| 9 |
+
processed_image, blink_count, hand_gesture_detected, smartphone_detected = anti_spoofing_system.process_single_frame(image)
|
| 10 |
+
|
| 11 |
+
# Return the results along with the processed image
|
| 12 |
+
return processed_image, blink_count, hand_gesture_detected, smartphone_detected
|
| 13 |
+
|
| 14 |
+
# Create the Gradio interface
|
| 15 |
+
iface = gr.Interface(
|
| 16 |
+
fn=process_frame,
|
| 17 |
+
inputs=gr.inputs.Image(shape=(720, 1280)),
|
| 18 |
+
outputs=[
|
| 19 |
+
gr.outputs.Image(type="auto", label="Processed Image"),
|
| 20 |
+
gr.outputs.Textbox(label="Blink Count"),
|
| 21 |
+
gr.outputs.Textbox(label="Hand Gesture Detected"),
|
| 22 |
+
gr.outputs.Textbox(label="Smartphone Detected")
|
| 23 |
+
],
|
| 24 |
+
title="Anti-Spoofing System",
|
| 25 |
+
description="Upload an image to check for spoofing indicators."
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
# Run the Gradio app
|
| 29 |
+
if __name__ == "__main__":
|
| 30 |
+
iface.launch()
|