|
|
import gradio as gr |
|
|
import cv2 |
|
|
import numpy as np |
|
|
import random |
|
|
|
|
|
|
|
|
OTP = random.randint(1000, 9999) |
|
|
|
|
|
|
|
|
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) |
|
|
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" |
|
|
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." |
|
|
|
|
|
|
|
|
with gr.Blocks() as demo: |
|
|
gr.Markdown("# π¦ ATM Security System π (Face + PIN + OTP)") |
|
|
|
|
|
|
|
|
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_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_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() |
|
|
|