-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
71 lines (50 loc) · 1.89 KB
/
README.Rmd
File metadata and controls
71 lines (50 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# megadetector
<!-- badges: start -->
[](https://github.com/boettiger-lab/megadetector/actions/workflows/check-standard.yaml)
[](https://github.com/boettiger-lab/megadetector/actions/workflows/docker-publish.yml)
<!-- badges: end -->
The `megadetector` package provides an R wrapper for the [MegaDetector](https://github.com/agentmorris/MegaDetector) model, allowing users to detect animals, people, and vehicles in camera trap images using Python's MegaDetector v5+ from within R.
## Installation
You can install the package from GitHub:
```r
# install.packages("remotes")
remotes::install_github("boettiger-lab/megadetector")
```
## Setup
The package requires a Python environment. It can clean-install the necessary `megadetector` python package for you:
```{r setup, eval=FALSE}
library(megadetector)
# Installs megadetector python package if not present
install_megadetector()
```
## Usage
```r
library(megadetector)
# 1. Load the Model
# Automatically downloads the default model (MDV5A) to the user cache if not present
model <- load_model()
# 2. Get some test images
# (Bundled with the package for demonstration)
image_file <- system.file("img", "Caltech_Animal.jpg", package = "megadetector")
# 3. Detect and Classify
detections <- detect_image(model, image_file)
class_label <- get_classification(detections)
cli::cli_alert_info("Image class: {.strong {class_label}}")
if (length(detections) > 0) {
print(detections[[1]])
}
```
## License
MIT