File size: 1,992 Bytes
d1211d3 5945644 d1211d3 5945644 ed6a945 5945644 ed6a945 d1211d3 f16b03c d1211d3 f16b03c d1211d3 f16b03c d1211d3 f16b03c d1211d3 f16b03c d1211d3 ed6a945 d1211d3 ed6a945 d1211d3 f16b03c d1211d3 ed6a945 d1211d3 f16b03c d1211d3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
import gradio as gr
import cv2
import numpy as np
import random
# OTP Setup
OTP = random.randint(1000, 9999)
# Face Detection using OpenCV
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
def detect_face(image):
"""Detects a face in an uploaded image."""
img_array = np.array(image) # Convert Gradio input to NumPy array
gray = cv2.cvtColor(img_array, cv2.COLOR_RGB2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.1, 4)
if len(faces) > 0:
return "β
Face detected! Now enter your PIN."
return "β No face detected! Please try again."
def verify_pin(pin):
"""Checks if the entered PIN is correct."""
correct_pin = "1234" # Set your own PIN
if pin == correct_pin:
return f"β
PIN correct! Your OTP is {OTP}. Please enter OTP."
return "β Incorrect PIN. Try again."
def verify_otp(otp):
"""Verifies the entered OTP."""
if str(otp) == str(OTP):
return "β
Access Granted! Welcome."
return "β Incorrect OTP. Access Denied."
# Gradio UI
with gr.Blocks() as demo:
gr.Markdown("# π¦ ATM Security System π (Face + PIN + OTP)")
# Face Detection
img_input = gr.Image(type="numpy", label="Upload Your Image for Face Detection")
detect_button = gr.Button("π Detect Face")
face_result = gr.Textbox(label="Face Detection Status")
detect_button.click(fn=detect_face, inputs=img_input, outputs=face_result)
# PIN Verification
pin_input = gr.Textbox(label="Enter PIN", type="password")
pin_button = gr.Button("π Submit PIN")
pin_result = gr.Textbox(label="PIN Status")
pin_button.click(fn=verify_pin, inputs=pin_input, outputs=pin_result)
# OTP Verification
otp_input = gr.Textbox(label="Enter OTP")
otp_button = gr.Button("π’ Submit OTP")
otp_result = gr.Textbox(label="OTP Status")
otp_button.click(fn=verify_otp, inputs=otp_input, outputs=otp_result)
demo.launch()
|