Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
plants_detection_counting
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rupa.lingmore
plants_detection_counting
Commits
af53fb28
Commit
af53fb28
authored
Mar 22, 2022
by
rupa.lingmore
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parent
5a9b2f11
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
imagecount.py
imagecount.py
+46
-0
No files found.
imagecount.py
0 → 100644
View file @
af53fb28
from
yolov5processor.infer
import
ExecuteInference
import
glob
import
numpy
as
np
yp
=
ExecuteInference
(
weight
=
"E:
\b
uds
\b
est.pt"
)
faulty_count
=
0
good_count
=
0
rejected_count
=
0
image
=
cv2
.
imread
(
"E:
\b
uds
\
original-predicted images
\
IMG_20220305_223916_jpg.rf.522aaff60984faaa45ddf1b14bc5bb9f.jpg"
)
pred
=
yp
.
predict
(
image
)
print
(
pred
)
for
det
in
pred
:
conf
=
"{:.2f}"
.
format
(
int
(
det
[
'conf'
]
*
100
))
if
int
(
det
[
'conf'
]
*
100
)
>
50
:
# print(det['class'])
label
=
det
[
'class'
]
# print(label.item())
det
=
det
[
'points'
]
if
label
==
"faulty"
:
cv2
.
rectangle
(
image
,
(
int
(
det
[
0
]),
int
(
det
[
1
])),
(
int
(
det
[
2
]),
int
(
det
[
3
])),
(
0
,
0
,
255
),
2
)
cv2
.
putText
(
img
=
image
,
text
=
conf
+
label
,
org
=
(
int
(
det
[
0
]),
int
(
det
[
1
])
-
10
),
color
=
(
0
,
0
,
225
),
thickness
=
1
,
fontScale
=
0.5
,
fontFace
=
cv2
.
LINE_AA
)
faulty_count
+=
1
elif
label
==
"good"
:
cv2
.
rectangle
(
image
,
(
int
(
det
[
0
]),
int
(
det
[
1
])),
(
int
(
det
[
2
]),
int
(
det
[
3
])),
(
0
,
0
,
255
),
2
)
cv2
.
putText
(
img
=
image
,
text
=
conf
+
label
,
org
=
(
int
(
det
[
0
]),
int
(
det
[
1
])
-
10
),
color
=
(
0
,
0
,
225
),
thickness
=
1
,
fontScale
=
0.5
,
fontFace
=
cv2
.
LINE_AA
)
good_count
+=
1
elif
label
==
"rejected"
:
cv2
.
rectangle
(
image
,
(
int
(
det
[
0
]),
int
(
det
[
1
])),
(
int
(
det
[
2
]),
int
(
det
[
3
])),
(
0
,
0
,
255
),
2
)
cv2
.
putText
(
img
=
image
,
text
=
conf
+
label
,
org
=
(
int
(
det
[
0
]),
int
(
det
[
1
])
-
10
),
color
=
(
0
,
0
,
225
),
thickness
=
1
,
fontScale
=
0.5
,
fontFace
=
cv2
.
LINE_AA
)
rejected_count
+=
1
print
(
f
"good-{good_count}, faulty-{faulty_count}, rejected-{rejected_count}"
)
#from google.colab.patches import cv2_imshow
cv2
.
imshow
(
"image"
,
image
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment