Commit ce102990 authored by dasharatha.vamshi's avatar dasharatha.vamshi

changes

parent fd2117b4
......@@ -56,7 +56,6 @@ class Welspun_Classifier(ModelWrapper):
self.defect_type = ""
self.frame_skip_count = 25
self.counter = 0
self.k = 0
def _pre_process(self, x):
"""
......@@ -189,29 +188,28 @@ class Welspun_Classifier(ModelWrapper):
return exp_vec / np.sum(exp_vec)
def process_frame(self, frame):
if self.k % 10 == 0:
self.k = self.k + 1
starttime = time.time()
vino_frame = frame.copy()
# vino_frame = vino_frame[20:600,150:650]
vino_frame = vino_frame[5: 600, 70: 650]
images = np.ndarray(shape=(self.n, self.c, self.h, self.w))
images_hw = []
for i in range(self.n):
image = vino_frame
ih, iw = image.shape[:-1]
images_hw.append((ih, iw))
starttime = time.time()
vino_frame = frame.copy()
# vino_frame = vino_frame[20:600,150:650]
vino_frame = vino_frame[5: 600, 70: 650]
images = np.ndarray(shape=(self.n, self.c, self.h, self.w))
images_hw = []
for i in range(self.n):
image = vino_frame
ih, iw = image.shape[:-1]
images_hw.append((ih, iw))
if (ih, iw) != (self.h, self.w):
# log.warning("Image {} is resized from {} to {}".format(img, image.shape[:-1], (h, w)))
image = cv2.resize(image, (self.w, self.h))
image = self.normalize(image)
# 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
images[i] = image
# log.info("Batch size is {}".format(n))
#
# log.info("Starting inference in synchronous mode")
if (ih, iw) != (self.h, self.w):
# log.warning("Image {} is resized from {} to {}".format(img, image.shape[:-1], (h, w)))
image = cv2.resize(image, (self.w, self.h))
image = self.normalize(image)
# 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
images[i] = image
# log.info("Batch size is {}".format(n))
#
# log.info("Starting inference in synchronous mode")
if self.counter % 10 == 0:
start = time.time()
res = self.exec_net.infer(inputs={self.input_blob: images})
print(f"Inference time: {time.time() - start}")
......@@ -293,8 +291,7 @@ class Welspun_Classifier(ModelWrapper):
color=(0, 0, 255),
thickness=2,
fontScale=1, fontFace=cv2.LINE_AA)
self.send_payload("Split Defect Detected", resized_frame, "Split " + str(prob[3]), "#472020",
"#ed2020",
self.send_payload("Split Defect Detected", resized_frame, "Split " + str(prob[3]), "#472020", "#ed2020",
"sound_1")
logger.info(f"Probability: {prob}")
# if self.counter % 25 == 0:
......@@ -354,5 +351,6 @@ class Welspun_Classifier(ModelWrapper):
print("total time taken to process-------------> ", str(time.time() - starttime))
# logger.info(f"total time taken to process----------------- {time.time()-starttime}")
# cv2.imshow('res', frame)
else:
pass
return frame
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment