ultralytics 8.1.31 NCNN and CLIP updates (#9235)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Glenn Jocher 2024-03-22 15:51:50 -07:00 committed by GitHub
parent 41c2d8d99f
commit 3c179f87cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 77 additions and 60 deletions

View file

@ -385,14 +385,12 @@ class Results(SimpleClass):
BGR=True,
)
def tojson(self, normalize=False):
"""Convert the object to JSON format."""
def summary(self, normalize=False):
"""Convert the results to a summarized format."""
if self.probs is not None:
LOGGER.warning("Warning: Classify task do not support `tojson` yet.")
LOGGER.warning("Warning: Classify task do not support `summary` and `tojson` yet.")
return
import json
# Create list of detection dictionaries
results = []
data = self.boxes.data.cpu().tolist()
@ -413,8 +411,13 @@ class Results(SimpleClass):
result["keypoints"] = {"x": (x / w).tolist(), "y": (y / h).tolist(), "visible": visible.tolist()}
results.append(result)
# Convert detections to JSON
return json.dumps(results, indent=2)
return results
def tojson(self, normalize=False):
"""Convert the results to JSON format."""
import json
return json.dumps(self.summary(normalize=normalize), indent=2)
class Boxes(BaseTensor):