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

changes

parent fd2117b4
...@@ -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
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