Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -4,46 +4,14 @@ import gradio as gr
|
|
| 4 |
|
| 5 |
|
| 6 |
def my_app(img):
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
# Use minSize because for not
|
| 18 |
-
# bothering with extra-small
|
| 19 |
-
# dots that would look like STOP signs
|
| 20 |
-
stop_data = cv2.CascadeClassifier('stop_data.xml')
|
| 21 |
-
|
| 22 |
-
found = stop_data.detectMultiScale(img_gray,
|
| 23 |
-
minSize=(20, 20))
|
| 24 |
-
|
| 25 |
-
# Don't do anything if there's
|
| 26 |
-
# no sign
|
| 27 |
-
amount_found = len(found)
|
| 28 |
-
|
| 29 |
-
if amount_found != 0:
|
| 30 |
-
return ("S T O P!")
|
| 31 |
-
# There may be more than one
|
| 32 |
-
# sign in the image
|
| 33 |
-
# for (x, y, width, height) in found:
|
| 34 |
-
|
| 35 |
-
# # We draw a green rectangle around
|
| 36 |
-
# # every recognized sign
|
| 37 |
-
# cv2.rectangle(img_rgb, (x, y),
|
| 38 |
-
# (x + height, y + width),
|
| 39 |
-
# (0, 255, 0), 5)
|
| 40 |
-
|
| 41 |
-
# Creates the environment of
|
| 42 |
-
# the picture and shows it
|
| 43 |
-
plt.subplot(1, 1, 1)
|
| 44 |
-
plt.imshow(img_rgb)
|
| 45 |
-
plt.show()
|
| 46 |
-
return ("S T O P!")
|
| 47 |
|
| 48 |
|
| 49 |
gr.interface.Interface(fn=my_app, live=True, inputs=gr.Image(
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
def my_app(img):
|
| 7 |
+
grayscale_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
| 8 |
+
classifier = cv2.CascadeClassifier('classifier.xml')
|
| 9 |
+
analysedData = classifier.detectMultiScale(grayscale_image,
|
| 10 |
+
minSize=(20, 20))
|
| 11 |
+
if len(analysedData) != 0:
|
| 12 |
+
return ("S T O P!")
|
| 13 |
+
else:
|
| 14 |
+
return ("You're good to go :)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
gr.interface.Interface(fn=my_app, live=True, inputs=gr.Image(
|