Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ae6d761

Browse files
committed
add refactor for faster work code
1 parent 30746ff commit ae6d761

File tree

5 files changed

+1663
-233
lines changed

5 files changed

+1663
-233
lines changed

‎custom_paralel_threade_refactored.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,20 @@ def detect_objects(self, frame):
8585
bboxes = []
8686
for result in results:
8787
for box in result.boxes:
88+
# Get the class ID and bounding box coordinates
89+
cls_id = int(box.cls[0]) # Class ID
8890
x1, y1, x2, y2 = box.xyxy[0]
8991
w = int(x2 - x1)
9092
h = int(y2 - y1)
91-
if w > 0 and h > 0:
93+
94+
# Filter for class 0 only
95+
if cls_id == 0 and w > 0 and h > 0:
9296
bboxes.append((int(x1), int(y1), w, h))
97+
elif cls_id != 0:
98+
logging.debug(f"Skipping detection for class {cls_id}.")
9399
else:
94100
logging.warning(f"Detected invalid bounding box with zero area: {(x1, y1, w, h)}")
95-
logging.debug(f"Detected {len(bboxes)} bounding boxes.")
101+
logging.debug(f"Detected {len(bboxes)} bounding boxes for class 0.")
96102
return bboxes
97103
except Exception as e:
98104
logging.error(f"Error during object detection: {e}")

‎profiling_results.prof

67.6 KB
Binary file not shown.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /