GC信息的格式

[GC [<collector>: <starting occupancy1> -> <ending occupancy1>, <pause time1> secs] <starting occupancy3> -> <ending occupancy3>, <pause time3> secs]
<collector> GC为minor收集过程中使用的垃圾收集器起的内部名称.
<starting occupancy1> young generation 在进行垃圾收集前被对象使用的存储空间.
<ending occupancy1> young generation 在进行垃圾收集后被对象使用的存储空间
<pause time1> minor收集使应用暂停的时间长短(秒) 
<starting occupancy3> 整个堆(Heap Size)在进行垃圾收集前被对象使用的存储空间
<ending occupancy3> 整个堆(Heap Size)在进行垃圾收集后被对象使用的存储空间
<pause time3> 整个垃圾收集使应用暂停的时间长短(秒),包括major收集使应用暂停的时间(如果发生了major收集).


.GC信息的选项
-XX:+PrintGCDetails 显示GC的详细信息
-XX:+PrintGCApplicationConcurrentTime 打印应用执行的时间
-XX:+PrintGCApplicationStoppedTime 打印应用被暂停的时间
提示:1.":"后的"+"号表示开启此选项,如果是"-"号那么表示关闭此选项。
     2.在不同的选项和不同的收集方式和类型下输出的格式会有所不同。 

### GC10-DET 数据集转换为 COCO 格式的解决方案 #### 背景说明 GC10-DET 是一种工业检测数据集,主要用于目标检测任务。为了将其转化为 COCO (Common Objects in Context) 格式,需要重新整理其标注文件并按照 COCO 的 JSON 文件结构进行存储[^1]。 --- #### COCO 格式简介 COCO 数据集的标注文件是一个 JSON 文件,通常包含以下几个主要部分: 1. **info**: 描述数据集的信息。 2. **licenses**: 许可证信息。 3. **categories**: 类别定义。 4. **images**: 图像列表及其元信息(如宽度、高度、路径等)。 5. **annotations**: 对应每张图片的目标框标注信息(如类别 ID、边界框坐标、面积等)。 以下是 COCO 格式的一个简化示例: ```json { "info": {}, "licenses": [], "categories": [ {"id": 1, "name": "class_1"}, {"id": 2, "name": "class_2"} ], "images": [ { "id": 1, "file_name": "image_1.jpg", "width": 640, "height": 480 } ], "annotations": [ { "id": 1, "image_id": 1, "category_id": 1, "bbox": [100, 100, 200, 200], "area": 40000, "iscrowd": 0 } ] } ``` --- #### GC10-DET 数据集到 COCO 格式的转换方法 ##### 步骤概述 假设原始 GC10-DET 数据集中提供了如下信息: - 图片路径和名称。 - 边界框位置(`xmin`, `ymin`, `xmax`, `ymax` 或其他形式)。 - 类别标签。 可以编写脚本完成以下工作: 1. 遍历所有图片和对应的标注文件。 2. 将标注信息解析为 COCO 所需的标准格式。 3. 输出最终的 JSON 文件。 --- ##### Python 实现代码 下面提供了一个基于 Python 和 OpenCV 的实现方案,用于将 GC10-DET 数据集转换为 COCO 格式。 ```python import os import json from PIL import Image def convert_to_coco_format(gc10_det_dir, output_json_path): images = [] annotations = [] categories = [{"id": i + 1, "name": f"class_{i+1}"} for i in range(10)] # 假设有 10 个类别 annotation_id = 1 image_id = 1 # 遍历图片目录 for filename in os.listdir(os.path.join(gc10_det_dir, "images")): if not filename.endswith(".jpg"): continue img_path = os.path.join(gc10_det_dir, "images", filename) width, height = Image.open(img_path).size # 添加图片信息 images.append({ "id": image_id, "file_name": filename, "width": width, "height": height }) # 解析对应标注文件 label_filename = os.path.splitext(filename)[0] + ".txt" label_path = os.path.join(gc10_det_dir, "labels", label_filename) with open(label_path, "r") as f: lines = f.readlines() for line in lines: parts = list(map(float, line.strip().split())) category_id = int(parts[0]) + 1 # 类别索引从 1 开始 # 归一化坐标转绝对坐标 cx_norm, cy_norm, w_norm, h_norm = parts[1:] bbox_width = w_norm * width bbox_height = h_norm * height bbox_x = (cx_norm - w_norm / 2) * width bbox_y = (cy_norm - h_norm / 2) * height area = bbox_width * bbox_height # 添加标注信息 annotations.append({ "id": annotation_id, "image_id": image_id, "category_id": category_id, "bbox": [bbox_x, bbox_y, bbox_width, bbox_height], "area": area, "iscrowd": 0 }) annotation_id += 1 image_id += 1 # 构建完整的 COCO 格式字典 coco_data = { "info": {}, "licenses": [], "categories": categories, "images": images, "annotations": annotations } # 导出为 JSON 文件 with open(output_json_path, "w") as f: json.dump(coco_data, f) # 使用函数 convert_to_coco_format("/path/to/gc10-det/", "/output/coco_annotations.json") ``` 上述代码实现了以下功能: 1. 自动读取图片尺寸。 2. 处理 YOLO 格式的标注文件(归一化的中心点坐标),并将其转换为目标框的左上角坐标及宽高。 3. 按照 COCO 格式构建 JSON 文件。 --- #### 注意事项 1. 如果原始标注不是 YOLO 格式,则需要修改相应的解析逻辑。 2. 确保图片和标注文件一一对应,否则可能导致错误。 3. 可视化工具可以帮助验证生成的 COCO 格式是否正确。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值