Spaces:
Configuration error
Configuration error
Commit
·
d078086
1
Parent(s):
49ecb98
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,9 +3,10 @@ import gradio as gr
|
|
| 3 |
thres = 0.45 # Threshold to detect object
|
| 4 |
|
| 5 |
|
|
|
|
| 6 |
def Detection(filename):
|
| 7 |
cap = cv2.VideoCapture(filename)
|
| 8 |
-
|
| 9 |
|
| 10 |
cap.set(3,1280)
|
| 11 |
cap.set(4,720)
|
|
@@ -14,7 +15,7 @@ def Detection(filename):
|
|
| 14 |
error="in function 'cv::imshow'"
|
| 15 |
classNames= []
|
| 16 |
FinalItems=[]
|
| 17 |
-
classFile = '
|
| 18 |
with open(classFile,'rt') as f:
|
| 19 |
#classNames = f.read().rstrip('n').split('n')
|
| 20 |
classNames = f.readlines()
|
|
@@ -23,8 +24,8 @@ def Detection(filename):
|
|
| 23 |
# remove new line characters
|
| 24 |
classNames = [x.strip() for x in classNames]
|
| 25 |
print(classNames)
|
| 26 |
-
configPath = '
|
| 27 |
-
weightsPath = '
|
| 28 |
|
| 29 |
|
| 30 |
net = cv2.dnn_DetectionModel(weightsPath,configPath)
|
|
@@ -55,6 +56,10 @@ def Detection(filename):
|
|
| 55 |
|
| 56 |
#cv2.imshow("Output",img)
|
| 57 |
cv2.waitKey(10)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
except Exception as err:
|
| 59 |
print(err)
|
| 60 |
t=str(err)
|
|
@@ -64,7 +69,6 @@ def Detection(filename):
|
|
| 64 |
print(FinalItems)
|
| 65 |
return str(FinalItems)
|
| 66 |
|
| 67 |
-
|
| 68 |
interface = gr.Interface(fn=Detection,
|
| 69 |
inputs=["video"],
|
| 70 |
outputs="text",
|
|
|
|
| 3 |
thres = 0.45 # Threshold to detect object
|
| 4 |
|
| 5 |
|
| 6 |
+
|
| 7 |
def Detection(filename):
|
| 8 |
cap = cv2.VideoCapture(filename)
|
| 9 |
+
framecount=0
|
| 10 |
|
| 11 |
cap.set(3,1280)
|
| 12 |
cap.set(4,720)
|
|
|
|
| 15 |
error="in function 'cv::imshow'"
|
| 16 |
classNames= []
|
| 17 |
FinalItems=[]
|
| 18 |
+
classFile = 'coco.names'
|
| 19 |
with open(classFile,'rt') as f:
|
| 20 |
#classNames = f.read().rstrip('n').split('n')
|
| 21 |
classNames = f.readlines()
|
|
|
|
| 24 |
# remove new line characters
|
| 25 |
classNames = [x.strip() for x in classNames]
|
| 26 |
print(classNames)
|
| 27 |
+
configPath = 'ssd_mobilenet_v3_large_coco_2020_01_14.pbtxt'
|
| 28 |
+
weightsPath = 'frozen_inference_graph.pb'
|
| 29 |
|
| 30 |
|
| 31 |
net = cv2.dnn_DetectionModel(weightsPath,configPath)
|
|
|
|
| 56 |
|
| 57 |
#cv2.imshow("Output",img)
|
| 58 |
cv2.waitKey(10)
|
| 59 |
+
if framecount>cap.get(cv2.CAP_PROP_FRAME_COUNT):
|
| 60 |
+
break
|
| 61 |
+
else:
|
| 62 |
+
framecount+=1
|
| 63 |
except Exception as err:
|
| 64 |
print(err)
|
| 65 |
t=str(err)
|
|
|
|
| 69 |
print(FinalItems)
|
| 70 |
return str(FinalItems)
|
| 71 |
|
|
|
|
| 72 |
interface = gr.Interface(fn=Detection,
|
| 73 |
inputs=["video"],
|
| 74 |
outputs="text",
|