brxerq commited on
Commit
94ada36
·
1 Parent(s): 407b7fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -14
app.py CHANGED
@@ -1,30 +1,27 @@
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()
 
1
  import gradio as gr
2
  from anti_spoofing import AntiSpoofingSystem
3
 
4
+ # Instantiate your AntiSpoofingSystem outside of the function to avoid re-loading models
5
+ anti_spoofing_system = AntiSpoofingSystem()
6
+
7
  def process_frame(image):
8
+ # Since we're not processing a video stream, we process the single image
9
+ # Convert the image to grayscale, detect features, etc.
10
+ # Then return results (for this example, just returning the input image and dummy text)
11
  processed_image, blink_count, hand_gesture_detected, smartphone_detected = anti_spoofing_system.process_single_frame(image)
12
+ return processed_image, f"Blink Count: {blink_count}", f"Hand Gesture Detected: {hand_gesture_detected}", f"Smartphone Detected: {smartphone_detected}"
 
 
13
 
 
14
  iface = gr.Interface(
15
  fn=process_frame,
16
+ inputs=gr.inputs.Image(type="pil", label="Upload Image or Use Webcam"),
17
  outputs=[
18
+ gr.outputs.Image(type="pil", label="Processed Image"),
19
  gr.outputs.Textbox(label="Blink Count"),
20
  gr.outputs.Textbox(label="Hand Gesture Detected"),
21
  gr.outputs.Textbox(label="Smartphone Detected")
22
  ],
23
  title="Anti-Spoofing System",
24
+ description="Upload an image or capture from webcam to check for spoofing indicators."
25
  )
26
 
27
+ iface.launch()