Downloads · 30 days
0
imageomics/Drexel-metadata-generator
Drexel-metadata-generator is a object detection model from imageomics. Use it when you need objects located in an image. The card lists the license as mit.
This model was designed to generate metadata for images of [museum] fish specimens. In addition to the metadata and quality metrics achieved with our initial model (detailed in Automatic Metadata Generation for Fish S…
Downloads · 30 days
0
Access
Public
Updated Nov 18, 2025
Repo size
176 MB
Likes
0
Public
Click a slice to open those files.
.pth176 MB · 100%
From the Hugging Face model README
This model was designed to generate metadata for images of [museum] fish specimens. In addition to the metadata and quality metrics achieved with our initial model (detailed in Automatic Metadata Generation for Fish Specimen Image Collections, bioRXiv), this updated model also generates various geometric and statistical properties on the mask generated over the biological specimen presented. Some examples of the new analytical features include convex area, eccentricity, perimeter, and skew. The updates to our model further improve on the accuracy, and time and labor cost over human generation.
<!-- This modelcard aims to be a base template for new models. It has been generated using [this raw template](https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/templates/modelcard_template.md?plain=1). -->This model is based on Facebook AI Research’s (FAIR) detectron tool (the implementation of the Mask R-CNN architecture). There are five object classes identifiable by the model: fish, fish eyes, rulers, and the numbers two and three on rulers, as shown in Fig. 2, below. Of note is its capability to return pixel-by-pixel masks over detected objects.
![]() |
|---|
| Figure 2. |
Furthermore, detectron places no restriction on the number of object classes, can classify an arbitrary number of objects within a given image, and it is relatively straightforward to train it on COCO format datasets. Objects that have a confidence score of at least 30% are maintained for analysis. See the tables below for the number of class instances in the full (aggregate), INHS, and UWZM training datasets.
| Table 1: Aggregate training dataset | Table 2: INHS Training Dataset | Table 3: UWZM Training Dataset |
|---|
| Class | Number of Instances | Class | Number of Instances | Class | Number of Instances | ||
|---|---|---|---|---|---|---|---|
| Fish | 391 | Fish | 312 | Fish | 79 | ||
| Ruler | 1095 | Ruler | 1016 | Ruler | 79 | ||
| Eye | 550 | Eye | 471 | Eye | 79 | ||
| Two | 194 | Two | 115 | Two | 79 | ||
| Three | 194 | Three | 115 | Three | 79 |
See the Glossary below for a detailed list of the properties generated by the model.
Object detection is currently being performed on 5 detection classes (fish, fish eyes, rulers, and the twos and threes found on rulers). The current setup is performed on the INHS and UWZM biological specimen image repositories.
The authors have declared that no conflict of interest exists.
<!--### Recommendations--> <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. --> <!-- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations. -->Every dependency is stored in a Pipfile. To set this up, run the following commands:
pip install pipenv
pipenv install
There may be OS dependent installations one may need to perform.
To generate the metadata, run the following command:
pipenv run python3 gen_metadata.py [file_or_dir_name]
Usage:
gen_metadata.py [-h] [--device {cpu,cuda}] [--outfname OUTFNAME] [--maskfname MASKFNAME] [--visfname VISFNAME]
file_or_directory [limit]
The limit parameter will limit
the number of files processed in the directory. The limit positional argument is only applicable when passing a directory.
By default gen_metadata.py requires a GPU (cuda).
To use a CPU instead pass the --device cpu argument to gen_metadata.py.
The following three arguments are only supported when processing a single image file:
--outfname <filename> - When passed the script will save the output metadata JSON to <filename> instead of printing to the console (the default behavior when processing one file).--maskfname <filename> - Enables logic to save an output mask to <filename> for the single input file.--visfname <filename> - Changes the script to save the output visualization to <filename> instead of the hard coded location.These arguments are meant to simplify adding gen_metadata.py to a workflow that process files individually.
A Docker container is automatically built for each drexel_metadata release. This container has the requirements installed and includes the model file. To run the singularity container for a specific version follow this pattern:
singularity run docker://ghcr.io/hdr-bgnn/drexel_metadata:<release> gen_metadata.py ...
Labeled by hand using makesense.ai (Skalski, P.: Make Sense. https://github.com/SkalskiP/make-sense/ (2019)).
Initially, we had 64 examples of each class from the UWZM collection in the training set. One issue that we encountered was the lack of catfish (notorus genus) in the training set, which led to a high count of undetected eyes in the testing set. Visually it is difficult even for humans to determine the location of catfish eyes given that they are either very close to the color of the skin or do not look like normal fish eyes. Thus, 15 catfish images from each image dataset were added to the training set.
Setup:
{"image_folder_name": ["dataset_name.json"]}.conf variable at the top of the main() function to load the JSON file name created in the previous step.overall_prefix.txt file in the config folder. This file should have the absolute path to the directory in which all the image repositories will be stored.
/usr/local/bgnn/. There are various image folders like tulane, inhs_filtered, uwzm_filtered, etc.Finally, to train the model, run the following command:
pipenv run python3 train_model.py
To develop a tool to check the validity of metadata associated with an image, and generate things that are missing. Also includes various geometric and statistical properties on the mask generated over the biological specimen presented.
The metadata generated is extremely specific to our use case. In addition, we perform additional image processing techniques to improve our accuracies that may not work for other use cases. These include:
The metadata generated produces various statistical and geometric properties of a biological specimen image or collection in a JSON format. When a single file is passed, the data is yielded to the console (stdout). When a directory is passed, the data is stored in a JSON file.
Extremely minimal as a regular workstation computer was used for this paper.
Karnani, K., Pepper, J., Bakiş, Y. et al. Computational metadata generation methods for biological specimen image collections. Int J Digit Libr (2022). https://doi.org/10.1007/s00799-022-00342-1
J. Pepper, J. Greenberg, Y. Bakiş, X. Wang, H. Bart and D. Breen, "Automatic Metadata Generation for Fish Specimen Image Collections," 2021 ACM/IEEE Joint Conference on Digital Libraries (JCDL), 2021, pp. 31-40, doi: 10.1109/JCDL52503.2021.00015.
BibTeX:
@article{KPB2022,
title = "Computational metadata generation methods for biological specimen image collections",
author = "Karnani, Kevin and Pepper, Joel and Bak{\i}{\c s}, Yasin and Wang, Xiaojun and Bart, Jr, Henry and
Breen, David E and Greenberg, Jane",
journal = "International Journal on Digital Libraries",
year = 2022,
url = "https://doi.org/10.1007/s00799-022-00342-1",
doi = "10.1007/s00799-022-00342-1"
}
<!--
**APA:**
[More Information Needed] -->
| Property | Association | Type | Explanation |
|---|---|---|---|
| has_fish | Overall Image | Boolean | Whether a fish was found in the image. |
| fish_count | Overall Image | Integer | The quantity of fish present. |
| has_ruler | Overall Image | Boolean | Whether a ruler was found in the image. |
| ruler_bbox | Overall Image | 4 Tuple | The bounding box of the ruler (if found). |
| scale* | Overall Image | Float | The scale of the image in \(\frac{\mathrm{pixels}}{\mathrm{cm}}\). |
| bbox | Per Fish | 4 Tuple | The top left and bottom right coordinates of the bounding box for a fish. |
| background.mean | Per Fish | Float | The mean intensity of the background within a given fish's bounding box. |
| background.std | Per Fish | Float | The standard deviation of the background within a given fish's bounding box. |
| foreground.mean | Per Fish | Float | The mean intensity of the foreground within a given fish's bounding box. |
| foreground.std | Per Fish | Float | The standard deviation of the foreground within a given fish's bounding box. |
| contrast* | Per Fish | Float | The contrast between foreground and background intensities within a given fish's bounding box. |
| centroid | Per Fish | 4 Tuple | The centroid of a given fish's bitmask. |
| primary_axis* | Per Fish | 2D Vector | The unit length primary axis (eigenvector) for the bitmask of a given fish. |
| clock_value* | Per Fish | Integer | Fish's primary axis converted into an integer "clock value" between 1 and 12. |
| oriented_length* | Per Fish | Float | The length of the fish bounding box in centimeters. |
| mask | Per Fish | 2D Matrix | The bitmask of a fish in 0's and 1's. |
| pixel_analysis_failed | Per Fish | Boolean | Whether the pixel analysis process failed for a given fish. If true, detectron's mask and bounding box were used for metadata generation. |
| score | Per Fish | Float | The percent confidence score output by detectron for a given fish. |
| has_eye | Per Fish | Boolean | Whether an eye was found for a given fish. |
| eye_center | Per Fish | 2 Tuple | The centroid of a fish's eye. |
| side* | Per Fish | String | The side (i.e. 'left' or 'right') of the fish that is facing the camera (dependent on finding its eye). |
| area | Per Fish | Float | Area of fish in \(\mathrm{cm^2}\). |
| cont_length | Per Fish | Float | The longest contiguous length of the fish in centimeters. |
| cont_width | Per Fish | Float | The longest contiguous width of the fish in centimeters. |
| convex_area | Per Fish | Float | Area of convex hull image (smallest convex polygon that encloses the fish) in \(\mathrm{cm^2}\). |
| eccentricity | Per Fish | Float | Ratio of the focal distance over the major axis length of the ellipse that has the same second-moments as the fish. |
| extent | Per Fish | Float | Ratio of pixels of fish to pixels in the total bounding box. Computed as \(\frac{\mathrm{area}}{\mathrm{rows} * \mathrm{cols}}\) |
| feret_diameter_max | Per Fish | Float | The longest distance between points around the fish’s convex hull contour. |
| kurtosis | Per Fish | 2D Vector | The sharpness of the peaks of the frequency-distribution curve of mask pixel coordinates. |
| major_axis_length | Per Fish | Float | The length of the major axis of the ellipse that has the same normalized second central moments as the fish. |
| mask.encoding | Per Fish | String | The 8-way Freeman Encoding of the outline of the fish. |
| mask.start_coord | Per Fish | 2D Vector | The starting coordinate of the Freeman encoded mask. |
| minor_axis_length | Per Fish | Float | The length of the minor axis of the ellipse that has the same normalized second central moments as the fish. |
| oriented_width | Per Fish | Float | The width of the fish bounding box in centimeters. |
| perimeter | Per Fish | Float | The approximation of the contour in centimeters as a line through the centers of border pixels using 8-connectivity. |
| skew | Per Fish | 2D Vector | The measure of asymmetry of the frequency-distribution curve of mask pixel coordinates. |
| solidity | Per Fish | Float | The ratio of pixels in the fish to pixels of the convex hull image. |
| std | Per Fish | Float | The standard deviation of the mask pixel coordinate distribution. |
Research supported by NSF Office of Advanced Cyberinfrastructure (OAC) #1940233 and #1940322, with additional support from NSF Award #2118240. Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.
Computer Science Department, Drexel University, Philadelphia, PA, USA
Kevin Karnani, Joel Pepper (corresponding author) & David E. Breen
Biodiversity Research Institute, Tulane University, New Orleans, LA, USA
Yasin Bakiş, Xiaojun Wang & Henry Bart Jr.
Information Science Department, Drexel University, Philadelphia, PA, USA
Jane Greenberg
Elizabeth Campolongo and Joel Pepper
<!--## Model Card Contact [More Information Needed]-->