Edit model card

You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

mosquito-egg-detection

This object detection model is a finetuned version of microsoft/conditional-detr-resnet-50 model for detecting eggs (and clusters of eggs) of the Aedes aegypti mosquito.

The model was fine-tuned on the henryzord/mosquito-egg-detection dataset.

egg_detection

Model description

To be fulfilled.

Intended uses & limitations

To be fulfilled.

How to use

import numpy as np
from PIL import ImageDraw

import torch
from datasets import load_dataset
from transformers import AutoImageProcessor, AutoModelForObjectDetection

TOKEN = 'generate your token at https://huggingface.co/settings/tokens'

path_space = 'henryzord/mosquito-egg-detection'

image_processor = AutoImageProcessor.from_pretrained(path_space, token=TOKEN)
model = AutoModelForObjectDetection.from_pretrained(path_space, token=TOKEN)
dataset = load_dataset(path_space, token=TOKEN)
image = dataset['test'][np.random.randint(len(dataset['test']))]['image']

with torch.no_grad():
    inputs = image_processor(images=[image], return_tensors='pt')
    outputs = model(**inputs)
    target_sizes = torch.tensor([[image.size[1], image.size[0]]])
    results = image_processor.post_process_object_detection(outputs, threshold=0.3, target_sizes=target_sizes)[0]

for score, label, box in zip(results['scores'], results['labels'], results['boxes']):
    box = [round(i, 2) for i in box.tolist()]
    print(
        f"Detected {model.config.id2label[label.item()]} with confidence "
        f"{round(score.item(), 3)} at location {box}"
    )

draw = ImageDraw.Draw(image)

for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
    box = [round(i, 2) for i in box.tolist()]
    x, y, x2, y2 = tuple(box)
    draw.rectangle((x, y, x2, y2), outline="red", width=1)
    draw.text((x, y2 + 2), model.config.id2label[label.item()], fill='red')

image.show()

Training data

The model was fine-tuned on the henryzord/mosquito-egg-detection dataset. It was manually annotated by a team of students from Federal University of Santa Maria.

Training procedure

Available at this notebook.

Training hyperparameters

  • num_train_epochs: 100
  • learning_rate: 1e-05
  • auto_find_batch_size: True

Framework versions

  • Transformers: 4.42.1
  • Pytorch: 2.3.1
  • Datasets: 2.20.0
  • Tokenizers: 0.19.1
  • Timm: 1.0.7

BibTeX entry and citation info

@misc{
    author={Fulfill me},
    title={Fulfill me},
    year={2024},
    howpublished={
        Available at \url{
            henryzord/mosquito-egg-detection](https://huggingface.co/henryzord/mosquito-egg-detection
        }
    }
}
Downloads last month
35
Safetensors
Model size
43.5M params
Tensor type
F32
·
Inference Examples
Inference API (serverless) does not yet support pytorch models for this pipeline type.

Model tree for henryzord/mosquito-egg-detection

Finetuned
(40)
this model

Dataset used to train henryzord/mosquito-egg-detection

Evaluation results