microsoft / microsoft/MegaDetector

After installing MegaDetector CLI, modules still missing and unable to run CLI

Open
#33 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
50
Forks
7
PR merge metrics
No merged PRs in 30d

Description

Search before asking
  • I have searched the MegaDetector issues and found no similar bug report.
Bug

I installed MegaDetector CLI using the instructions on the page
https://microsoft.github.io/MegaDetector/cli/

I ran megadetector detect --input photo.jpg and it gave the error :

Traceback (most recent call last):
File "/home/eira/Projects/megadetector/bin/megadetector", line 5, in
from megadetector_core.cli import main
File "/home/eira/Projects/megadetector/MegaDetector/src/megadetector_core/init.py", line 18, in
from megadetector_core.detector import MegaDetectorV6, MegaDetectorV5
File "/home/eira/Projects/megadetector/MegaDetector/src/megadetector_core/detector.py", line 8, in
from PytorchWildlife.models import detection as pw_detection
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/PytorchWildlife/init.py", line 16, in
from .data import *
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/PytorchWildlife/data/init.py", line 3, in
from .bioacoustics import *
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/PytorchWildlife/data/bioacoustics/init.py", line 8, in
from .bioacoustics_annotations import AnnotationCreator, BaseReader
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/PytorchWildlife/data/bioacoustics/bioacoustics_annotations.py", line 3, in
import soundfile as sf
ModuleNotFoundError: No module named 'soundfile'

I fixed this by running pip install soundfile

after running megadetector detect --input photo.jpg again, it gave the error :

Traceback (most recent call last):
File "/home/eira/Projects/megadetector/bin/megadetector", line 5, in
from megadetector_core.cli import main
File "/home/eira/Projects/megadetector/MegaDetector/src/megadetector_core/init.py", line 18, in
from megadetector_core.detector import MegaDetectorV6, MegaDetectorV5
File "/home/eira/Projects/megadetector/MegaDetector/src/megadetector_core/detector.py", line 8, in
from PytorchWildlife.models import detection as pw_detection
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/PytorchWildlife/init.py", line 16, in
from .data import *
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/PytorchWildlife/data/init.py", line 3, in
from .bioacoustics import *
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/PytorchWildlife/data/bioacoustics/init.py", line 11, in
from .bioacoustics_spectrograms import *
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/PytorchWildlife/data/bioacoustics/bioacoustics_spectrograms.py", line 24, in
import librosa
ModuleNotFoundError: No module named 'librosa'

I fixed this by running pip install librosa

after running megadetector detect --input photo.jpg again, it gave the error :

Traceback (most recent call last):
File "/home/eira/Projects/megadetector/bin/megadetector", line 5, in
from megadetector_core.cli import main
File "/home/eira/Projects/megadetector/MegaDetector/src/megadetector_core/init.py", line 18, in
from megadetector_core.detector import MegaDetectorV6, MegaDetectorV5
File "/home/eira/Projects/megadetector/MegaDetector/src/megadetector_core/detector.py", line 8, in
from PytorchWildlife.models import detection as pw_detection
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/PytorchWildlife/init.py", line 17, in
from .models import *
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/PytorchWildlife/models/init.py", line 2, in
from .detection import *
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/PytorchWildlife/models/detection/init.py", line 1, in
from .ultralytics_based import *
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/PytorchWildlife/models/detection/ultralytics_based/init.py", line 1, in
from .yolov5_base import *
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/PytorchWildlife/models/detection/ultralytics_based/yolov5_base.py", line 17, in
from yolov5.utils.general import non_max_suppression, scale_boxes
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/yolov5/init.py", line 1, in
from yolov5.helpers import YOLOv5
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/yolov5/helpers.py", line 4, in
from yolov5.models.common import AutoShape, DetectMultiBackend
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/yolov5/models/common.py", line 28, in
from yolov5.utils.dataloaders import exif_transpose, letterbox
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/yolov5/utils/dataloaders.py", line 31, in
from yolov5.utils.augmentations import (Albumentations, augment_hsv, classify_albumentations, classify_transforms, copy_paste,
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/yolov5/utils/augmentations.py", line 15, in
from yolov5.utils.general import LOGGER, check_version, colorstr, resample_segments, segment2box, xywhn2xyxy
File "/home/eira/Projects/megadetector/lib/python3.12/site-packages/yolov5/utils/general.py", line 34, in
import pkg_resources as pkg
ModuleNotFoundError: No module named 'pkg_resources'

When I run pip install pkg_resources, I get the error :

ERROR: Could not find a version that satisfies the requirement pkg_resources (from versions: none)
ERROR: No matching distribution found for pkg_resources

Is there something I can do to get it working?

Environment
  • PytorchWildlife 1.3.0
  • Xubuntu 24.04 LTS
  • Python 3.12.3
Minimal Reproducible Example

Install megadetector CLI using the instructions
https://microsoft.github.io/MegaDetector/cli/

run megadetector detect --input photo.jpg

This produces the results above

Additional

No response

Are you willing to submit a PR?
  • Yes I'd like to help by submitting a PR!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CLI installation instructions and the import path in MegaDetector/src/megadetector_core/detector.py, then reproduce megadetector detect --input photo.jpg under Python 3.12. Check how the CLI declares and installs its dependencies; done means a clean installation reaches the command without the reported missing-module errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
build-system, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.