Exemplo n.º 1
0
def expected_records():
    source = Path(mantisshrimp.__file__).parent.parent / "samples"
    dataset = torchvision.datasets.CocoDetection(source,
                                                 source / "annotations.json")
    return dataset.coco.dataset
Exemplo n.º 2
0
def test_open_img():
    fn = Path(__file__).parent.parent.parent
    fn = str(fn / "samples/images/000000000089.jpg")
    assert open_img(fn).shape == (480, 640, 3)
    assert open_img(fn, gray=True).shape == (480, 640)
Exemplo n.º 3
0
import pytest
from mantisshrimp.imports import Path, json, plt
from mantisshrimp import *

source = Path(__file__).absolute().parent.parent.parent / "samples"


def test_info_parser():
    parser = test_utils.sample_image_info_parser()
    infos = parser.parse()[0]
    assert len(infos) == 6
    expected = {
        "imageid": 0,
        "filepath": source / "images/000000128372.jpg",
        "height": 427,
        "width": 640,
    }
    assert infos[0] == expected


def test_coco_annotation_parser():
    parser = test_utils.sample_annotation_parser()
    annotations = parser.parse()[0]
    annotation = annotations[0]
    assert len(annotations) == 5
    assert annotation["imageid"] == 0
    assert annotation["labels"] == [4]
    assert pytest.approx(annotation["bboxes"][0].xyxy) == [
        175.14,
        175.68,
        496.2199,
Exemplo n.º 4
0
from mantisshrimp import *
from mantisshrimp.imports import Path, json
from mantisshrimp.imports import ABC

import mantisshrimp

source = Path(mantisshrimp.__file__).parent.parent / "samples"
annots_dict = json.loads((source / "annotations.json").read())

image_info_parser = COCOImageInfoParser(annots_dict["images"], source)
records = image_info_parser.parse_dicted()
records

coco_annotation_parser = COCOAnnotationParser2(annots_dict["annotations"])
annotations = coco_annotation_parser.parse_dicted()
annotations