Python refactorings and simplifications (#7549)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: Hassaan Farooq <103611273+hassaanfarooq01@users.noreply.github.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Glenn Jocher 2024-01-12 19:34:03 +01:00 committed by GitHub
parent 0da13831cf
commit f6309b8e70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 127 additions and 189 deletions

View file

@ -175,9 +175,7 @@ class Yolov8TFLite:
img = np.ascontiguousarray(image)
# n, h, w, c
image = img.astype(np.float32)
image_data = image / 255
# Return the preprocessed image data
return image_data
return image / 255
def postprocess(self, input_image, output):
"""
@ -194,7 +192,7 @@ class Yolov8TFLite:
boxes = []
scores = []
class_ids = []
for i, pred in enumerate(output):
for pred in output:
pred = np.transpose(pred)
for box in pred:
x, y, w, h = box[:4]
@ -221,7 +219,7 @@ class Yolov8TFLite:
box[3] = box[3] / gain
score = scores[i]
class_id = class_ids[i]
if scores[i] > 0.25:
if score > 0.25:
print(box, score, class_id)
# Draw the detection on the input image
self.draw_detections(input_image, box, score, class_id)