Git Product home page Git Product logo

Comments (2)

ChristianMarzahl avatar ChristianMarzahl commented on July 2, 2024

Hi,

the EIPH_WSI dataset is currently not publicly available. Please, use for example the COCO_SAMPLE dataset.

With kind regards,
Christian

from objectdetection.

ChristianMarzahl avatar ChristianMarzahl commented on July 2, 2024

Take a look at the example code below for inspiration.

CATEGORIES = []
for i in range(5):
    CATEGORIES += {
        'id': str(i),
        'name': str(i),
        'supercategory': 'Hemosiderophages',
    },

coco_output = {
    # "info": INFO,
    #  "licenses": LICENSES,
    "categories": CATEGORIES,
    "images": [],
    "annotations": []
}

image_id = 1
annotation_id = 1

path = Path('/data/Datasets/)

# for each file to convert into the coco format
for file in tqdm(train_files):

    # get boxes and labels in the format [[x1,x2,w,h],   [x1,x2,w,h]], [1,2]
    boxes, labels = get_y_func(file)
    boxes = np.array(boxes)
    labels = np.array(labels)
    classes = list(set(labels))

    for image, y in zip(x_batch, y_batch):
        boxes, labels = y

        name = file.file.stem + "_" + str(image_id) + ".png"

        image_info = {
            "id": image_id,
            "file_name": name,
            "width": image.shape[0],
            "height": image.shape[1],
        }

        coco_output["images"].append(image_info)

        for box, label in zip(boxes, labels):
            annotation_info = {
                "id": annotation_id,
                "image_id": image_id,
                "category_id": str(label),
                "bbox": [int(box[0]), int(box[1]), int(box[2]-box[0]), int(box[3]-box[1])]
            }
            coco_output["annotations"].append(annotation_info)
            annotation_id = annotation_id + 1

        image_id += 1

with open(str(path/'WIPH_WSI_Coco.json'), 'w') as output_json_file:
    json.dump(coco_output, output_json_file)

from objectdetection.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.