Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
Welspun-Classification
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
dasharatha.vamshi
Welspun-Classification
Commits
ce102990
Commit
ce102990
authored
Feb 15, 2021
by
dasharatha.vamshi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes
parent
fd2117b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
26 deletions
+24
-26
scripts/welspun_classifier.py
scripts/welspun_classifier.py
+24
-26
No files found.
scripts/welspun_classifier.py
View file @
ce102990
...
@@ -56,7 +56,6 @@ class Welspun_Classifier(ModelWrapper):
...
@@ -56,7 +56,6 @@ class Welspun_Classifier(ModelWrapper):
self
.
defect_type
=
""
self
.
defect_type
=
""
self
.
frame_skip_count
=
25
self
.
frame_skip_count
=
25
self
.
counter
=
0
self
.
counter
=
0
self
.
k
=
0
def
_pre_process
(
self
,
x
):
def
_pre_process
(
self
,
x
):
"""
"""
...
@@ -189,29 +188,28 @@ class Welspun_Classifier(ModelWrapper):
...
@@ -189,29 +188,28 @@ class Welspun_Classifier(ModelWrapper):
return
exp_vec
/
np
.
sum
(
exp_vec
)
return
exp_vec
/
np
.
sum
(
exp_vec
)
def
process_frame
(
self
,
frame
):
def
process_frame
(
self
,
frame
):
if
self
.
k
%
10
==
0
:
starttime
=
time
.
time
()
self
.
k
=
self
.
k
+
1
vino_frame
=
frame
.
copy
()
starttime
=
time
.
time
()
# vino_frame = vino_frame[20:600,150:650]
vino_frame
=
frame
.
copy
()
vino_frame
=
vino_frame
[
5
:
600
,
70
:
650
]
# vino_frame = vino_frame[20:600,150:650]
images
=
np
.
ndarray
(
shape
=
(
self
.
n
,
self
.
c
,
self
.
h
,
self
.
w
))
vino_frame
=
vino_frame
[
5
:
600
,
70
:
650
]
images_hw
=
[]
images
=
np
.
ndarray
(
shape
=
(
self
.
n
,
self
.
c
,
self
.
h
,
self
.
w
))
for
i
in
range
(
self
.
n
):
images_hw
=
[]
image
=
vino_frame
for
i
in
range
(
self
.
n
):
ih
,
iw
=
image
.
shape
[:
-
1
]
image
=
vino_frame
images_hw
.
append
((
ih
,
iw
))
ih
,
iw
=
image
.
shape
[:
-
1
]
images_hw
.
append
((
ih
,
iw
))
if
(
ih
,
iw
)
!=
(
self
.
h
,
self
.
w
):
if
(
ih
,
iw
)
!=
(
self
.
h
,
self
.
w
):
# log.warning("Image {} is resized from {} to {}".format(img, image.shape[:-1], (h, w)))
# log.warning("Image {} is resized from {} to {}".format(img, image.shape[:-1], (h, w)))
image
=
cv2
.
resize
(
image
,
(
self
.
w
,
self
.
h
))
image
=
cv2
.
resize
(
image
,
(
self
.
w
,
self
.
h
))
image
=
self
.
normalize
(
image
)
image
=
self
.
normalize
(
image
)
# log.warning("Image {} is resized from {} to {}".format(args.input[i], image.shape[:-1], (h, w)))
# log.warning("Image {} is resized from {} to {}".format(args.input[i], image.shape[:-1], (h, w)))
image
=
image
.
transpose
((
2
,
0
,
1
))
# Change data layout from HWC to CHW
image
=
image
.
transpose
((
2
,
0
,
1
))
# Change data layout from HWC to CHW
images
[
i
]
=
image
images
[
i
]
=
image
# log.info("Batch size is {}".format(n))
# log.info("Batch size is {}".format(n))
#
#
# log.info("Starting inference in synchronous mode")
# log.info("Starting inference in synchronous mode")
if
self
.
counter
%
10
==
0
:
start
=
time
.
time
()
start
=
time
.
time
()
res
=
self
.
exec_net
.
infer
(
inputs
=
{
self
.
input_blob
:
images
})
res
=
self
.
exec_net
.
infer
(
inputs
=
{
self
.
input_blob
:
images
})
print
(
f
"Inference time: {time.time() - start}"
)
print
(
f
"Inference time: {time.time() - start}"
)
...
@@ -293,8 +291,7 @@ class Welspun_Classifier(ModelWrapper):
...
@@ -293,8 +291,7 @@ class Welspun_Classifier(ModelWrapper):
color
=
(
0
,
0
,
255
),
color
=
(
0
,
0
,
255
),
thickness
=
2
,
thickness
=
2
,
fontScale
=
1
,
fontFace
=
cv2
.
LINE_AA
)
fontScale
=
1
,
fontFace
=
cv2
.
LINE_AA
)
self
.
send_payload
(
"Split Defect Detected"
,
resized_frame
,
"Split "
+
str
(
prob
[
3
]),
"#472020"
,
self
.
send_payload
(
"Split Defect Detected"
,
resized_frame
,
"Split "
+
str
(
prob
[
3
]),
"#472020"
,
"#ed2020"
,
"#ed2020"
,
"sound_1"
)
"sound_1"
)
logger
.
info
(
f
"Probability: {prob}"
)
logger
.
info
(
f
"Probability: {prob}"
)
# if self.counter % 25 == 0:
# if self.counter % 25 == 0:
...
@@ -354,5 +351,6 @@ class Welspun_Classifier(ModelWrapper):
...
@@ -354,5 +351,6 @@ class Welspun_Classifier(ModelWrapper):
print
(
"total time taken to process-------------> "
,
str
(
time
.
time
()
-
starttime
))
print
(
"total time taken to process-------------> "
,
str
(
time
.
time
()
-
starttime
))
# logger.info(f"total time taken to process----------------- {time.time()-starttime}")
# logger.info(f"total time taken to process----------------- {time.time()-starttime}")
# cv2.imshow('res', frame)
# cv2.imshow('res', frame)
else
:
pass
return
frame
return
frame
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