Empyt classifications with AI4GAmazonRainforest
Search before asking
- [x] I have searched the Pytorch-Wildlife issues and found no similar bug report.
Bug
Hi there,
I would be interested in using AI4GAmazonRainforest Classification Model, but unforunately the resulting json files always has completely empty columns for the classification. The detection works though. I am not sure what I am doing wrong. I have tried various different images from our Camera Trap project in Bolivia, but sofar without any success. My code looks likes this:
def batch_detect_classify(image_folder, md_output_file, class_output_file, model_file): from PytorchWildlife.models import detection as pw_detection from PytorchWildlife.models import classification as pw_classification from PytorchWildlife.data import datasets as pw_data from PytorchWildlife.data import transforms as pw_trans from PytorchWildlife import utils as pw_utils import torch from torch.utils.data import DataLoader from PIL import ImageFile ImageFile.LOAD_TRUNCATED_IMAGES = True
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
#' Initializing the MegaDetectorV6 model for image detection detection_model = pw_detection.MegaDetectorV6(device=DEVICE, pretrained=True, version=model_file)
#' Classification model classification_model = pw_classification.AI4GAmazonRainforest(device=DEVICE, version='v2')
#' Performing batch detection on the images det_results = detection_model.batch_image_detection(image_folder, batch_size=16)
pw_utils.save_detection_json(det_results, md_output_file, categories=detection_model.CLASS_NAMES, exclude_category_ids=[], # Category IDs can be found in the definition of each model. exclude_file_path=None)
clf_results = classification_model.batch_image_classification(det_results=det_results, id_strip=image_folder)
#' Saving the detection results in timelapse JSON format pw_utils.save_detection_classification_timelapse_json(det_results=det_results, clf_results=clf_results, det_categories=detection_model.CLASS_NAMES, clf_categories=classification_model.CLASS_NAMES, output_path=class_output_file)
Any ideas why the classification result turns out empty is highly appreciated. Thanks,
Matt
Environment
No response
Minimal Reproducible Example
No response
Additional
No response
Are you willing to submit a PR?
- [ ] Yes I'd like to help by submitting a PR!