术语表

JSON

了解 JSON 如何通过无缝数据交换、模型配置和实时应用简化人工智能和 ML 工作流程。

使用Ultralytics HUB 对YOLO 模型进行简单培训

了解更多

JSON, or JavaScript Object Notation, is a lightweight and human-readable data format widely used for data interchange, especially in web applications and data-driven systems. Its simplicity and ease of parsing by machines have made it a cornerstone in modern programming, including within the realm of Artificial Intelligence (AI) and Machine Learning (ML). JSON facilitates seamless data exchange, model configuration, and efficient real-time applications, making it an indispensable tool for developers and researchers. It provides a standardized way to structure data that both humans and computers can easily understand, as defined by the official ECMA-404 JSON Data Interchange Standard. More information can also be found at JSON.org.

主要特点

JSON's structure is built upon two fundamental elements:

  1. Key-Value Pairs: Collections of name/value pairs, often referred to as objects, dictionaries, or associative arrays in different programming languages. The key is always a string, and the value can be a string, number, boolean, array, or another JSON object.
  2. Ordered Lists: Ordered sequences of values, known as arrays or lists. Values in an array can be of any valid JSON data type.

This straightforward structure makes JSON files easy to create, read, and modify. It is language-agnostic, meaning it can be used across different programming languages like Python and platforms without compatibility issues, making it highly versatile for distributed systems and microservices.

人工智能和 ML 的应用

JSON 在人工智能和 ML 工作流程的各个方面都发挥着至关重要的作用:

  • Model Configuration: While YAML is often preferred for complex configurations due to its enhanced readability, JSON is frequently used in API calls to specify configuration parameters or within simpler configuration files.
  • Data Annotation and Datasets: In computer vision (CV), JSON is a common format for storing annotations for tasks like object detection and image segmentation. Annotation files often contain lists of objects, each with class labels, bounding box coordinates, or segmentation polygons represented in JSON format. Many standard datasets like COCO use JSON for their annotation structure.
  • API Communication: JSON is the de facto standard for data exchange in web APIs, including those used in AI and ML services. When interacting with AI models hosted via cloud computing platforms or dedicated endpoints using protocols like REST, input data (e.g., image URLs, text) is often sent as a JSON payload, and the model's predictions (e.g., detected objects, class probabilities, confidence scores) are returned in JSON format. The Ultralytics Inference API utilizes JSON for request and response formatting.
  • Storing Model Results: Results from model inference or evaluation, such as predicted classes, bounding boxes, or performance metrics like mean Average Precision (mAP), can be conveniently stored in JSON files. This structured format makes results easy to parse, analyze, or integrate into larger MLOps pipelines.

真实案例

下面是几个例子,说明 JSON 在人工智能和 ML 中的实际应用:

  1. Autonomous Vehicles: Sensor data from cameras, lidar, and radar in self-driving cars often needs to be processed and communicated between different system components. JSON can be used to structure this data, representing detected objects with their types, positions, velocities, and confidence levels, before feeding it into decision-making algorithms, often powered by deep learning models. Companies like Waymo rely on robust data formats for their complex systems.
  2. Ultralytics HUB: When interacting with Ultralytics HUB programmatically via its API, requests to initiate training jobs, upload datasets, or retrieve model performance metrics often involve sending and receiving data formatted as JSON. This allows seamless integration of HUB capabilities into custom workflows and applications.

JSON vs. Other Data Formats

It's helpful to compare JSON with other common data serialization formats:

  • YAML (YAML Ain't Markup Language): YAML prioritizes human readability and is often preferred for configuration files (e.g., defining model architectures or training parameters). While JSON can also be used for configuration, YAML's syntax (using indentation) is generally considered cleaner and easier to read for complex nested structures. JSON is typically favored for data interchange via APIs due to its simpler parsing rules and widespread support.
  • XML (eXtensible Markup Language): XML is another markup language used for encoding documents in a format that is both human-readable and machine-readable. Compared to JSON, XML is more verbose due to its use of closing tags and tends to be more complex to parse. While still used in enterprise systems and specific standards like SOAP, JSON has largely replaced XML in web applications and modern APIs due to its simplicity and lower overhead.

In summary, JSON's lightweight nature, human readability, and ease of parsing make it a highly effective and widely adopted format for structuring and exchanging data in AI and ML systems, particularly for API communication and storing structured results. Its compatibility across programming languages ensures smooth integration within diverse technology stacks, from data annotation and data preprocessing stages to final model deployment using tools like Ultralytics YOLO.

阅读全部