INNER CODE UNIT · Python

save_annotations

virajmavani/semi-auto-image-annotation-tool · web/backend/main.py:313

async def save_annotations(request: SaveAnnotationRequest):
    """Save annotations to CSV and VOC XML format"""
    try:
        from pascal_voc_writer import Writer

        # Save to CSV (use csv.writer to prevent CSV injection)
        csv_path = ANNOTATIONS_DIR / "annotations.csv"
        with open(csv_path, "a", newline="") as f:
            writer_csv = csv.writer(f)
            for bbox in request.bboxes:
                writer_csv.writerow([
                    request.image_name, bbox.x1, bbox.y1,
                    bbox.x2, bbox.y2, bbox.label
                ])

        # Save to VOC XML
        voc_dir = ANNOTATIONS_DIR / "annotations_voc"
        voc_dir.mkdir(exist_ok=True)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…