File size: 702 Bytes
4b11fbd
 
 
 
 
 
 
 
 
 
 
77a8ad2
4b11fbd
77a8ad2
4b11fbd
ff99dcb
4b11fbd
 
77a8ad2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import cv2
import gradio as gr


def my_app(img):
    grayscale_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    classifier = cv2.CascadeClassifier('classifier.xml')
    analysedData = classifier.detectMultiScale(grayscale_image,
                                               minSize=(20, 20))
    if len(analysedData) != 0:
        for (x, y, width, height) in analysedData:
            return (cv2.rectangle(img, (x, y),
                          (x + height, y + width),
                          (0, 255, 0), 5), "STOP")
    else:
        return (cv2.imread("thumbs_up.jpg"), "You may continue.")


gr.interface.Interface(fn=my_app, live=True, inputs="image", outputs=["image", "text"]).launch()