ultralytics 8.2.53 Heatmaps fix for empty images (#14329)

Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: RizwanMunawar <chr043416@gmail.com>
This commit is contained in:
Francesco Mattioli 2024-07-10 23:38:20 +02:00 committed by GitHub
parent 2d332a1cb1
commit 95736975fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 9 deletions

View file

@ -1,6 +1,6 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license # Ultralytics YOLO 🚀, AGPL-3.0 license
__version__ = "8.2.52" __version__ = "8.2.53"
import os import os

View file

@ -60,9 +60,9 @@ class Heatmap:
self.heatmap_alpha = heatmap_alpha self.heatmap_alpha = heatmap_alpha
# Predict/track information # Predict/track information
self.boxes = None self.boxes = []
self.track_ids = None self.track_ids = []
self.clss = None self.clss = []
self.track_history = defaultdict(list) self.track_history = defaultdict(list)
# Region & Line Information # Region & Line Information
@ -107,16 +107,17 @@ class Heatmap:
print("Using Circular shape now") print("Using Circular shape now")
self.shape = "circle" self.shape = "circle"
def extract_results(self, tracks, _intialized=False): def extract_results(self, tracks):
""" """
Extracts results from the provided data. Extracts results from the provided data.
Args: Args:
tracks (list): List of tracks obtained from the object tracking process. tracks (list): List of tracks obtained from the object tracking process.
""" """
if tracks[0].boxes.id is not None:
self.boxes = tracks[0].boxes.xyxy.cpu() self.boxes = tracks[0].boxes.xyxy.cpu()
self.clss = tracks[0].boxes.cls.cpu().tolist() self.clss = tracks[0].boxes.cls.tolist()
self.track_ids = tracks[0].boxes.id.int().cpu().tolist() self.track_ids = tracks[0].boxes.id.int().tolist()
def generate_heatmap(self, im0, tracks): def generate_heatmap(self, im0, tracks):
""" """
@ -138,7 +139,7 @@ class Heatmap:
self.extract_results(tracks) self.extract_results(tracks)
self.annotator = Annotator(self.im0, self.tf, None) self.annotator = Annotator(self.im0, self.tf, None)
if self.track_ids is not None: if self.track_ids:
# Draw counting region # Draw counting region
if self.count_reg_pts is not None: if self.count_reg_pts is not None:
self.annotator.draw_region( self.annotator.draw_region(