Create README.md
Browse files- unimodal-bathy-bnn/README.md +90 -0
unimodal-bathy-bnn/README.md
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
metrics:
|
6 |
+
- accuracy
|
7 |
+
base_model:
|
8 |
+
- microsoft/resnet-50
|
9 |
+
pipeline_tag: image-classification
|
10 |
+
tags:
|
11 |
+
- AUV
|
12 |
+
- biology
|
13 |
+
- marine
|
14 |
+
- sonar
|
15 |
+
- bathymetry
|
16 |
+
- unimodal
|
17 |
+
- ecology
|
18 |
+
- robotics
|
19 |
+
---
|
20 |
+
|
21 |
+
# Model Card: Unimodal Bathymetry Bayesian Neural Network Classifier
|
22 |
+
|
23 |
+
This model is a Bayesian Neural Network (BNN) classifier, specifically a `ResNet50Custom` implementation, designed for the classification of AUV bathymetry data. It utilizes a ResNet50 backbone, pre-trained on ImageNet, adapted for 3-channel bathymetry inputs. As a BNN, it provides uncertainty estimates alongside its predictions, which can be valuable for decision-making in uncertain underwater environments.
|
24 |
+
|
25 |
+
---
|
26 |
+
|
27 |
+
## Model Details
|
28 |
+
|
29 |
+
### Model Description
|
30 |
+
|
31 |
+
This model is a Bayesian Neural Network (BNN) classifier, specifically a `ResNet50Custom` implementation, specialized for the classification of **AUV bathymetry data**. It leverages a **ResNet50** backbone (pre-trained on ImageNet-1K) as its primary feature extractor. The model's input layer (`conv1`) has been adapted to handle 3 channels, assuming the bathymetry data is preprocessed into a 3-channel image-like format (e.g., repeated grayscale or encoded depth/slope information).
|
32 |
+
|
33 |
+
As a **Bayesian Neural Network**, it provides valuable uncertainty estimates alongside its class predictions, making it suitable for applications where quantifying confidence in predictions is important.
|
34 |
+
|
35 |
+
* **Developed by:** Sams-Tom
|
36 |
+
* **Shared by:** Sams-Tom
|
37 |
+
* **Model type:** Bayesian Neural Network (BNN), Bathymetry Classifier (Computer Vision)
|
38 |
+
* **Language(s) (NLP):** N/A (Not an NLP model)
|
39 |
+
* **License:** MIT
|
40 |
+
* **Finetuned from model [optional]:** ResNet50 (pre-trained on ImageNet-1K)
|
41 |
+
|
42 |
+
### Model Sources
|
43 |
+
|
44 |
+
* **Repository:** `https://huggingface.co/sams-tom/multimodal-auv-bathy-bnn-classifier`
|
45 |
+
* **Paper:** [In development]
|
46 |
+
* **Demo [optional]:** [More Information Needed: If there's a live demo or notebook, please link it here.]
|
47 |
+
|
48 |
+
---
|
49 |
+
|
50 |
+
|
51 |
+
## How to Get Started with the Model
|
52 |
+
|
53 |
+
To use this model, ensure you have `torch`, `huggingface_hub`, and `bayesian-torch` installed (`pip install torch huggingface_hub bayesian-torch`).
|
54 |
+
|
55 |
+
```python
|
56 |
+
from transformers import AutoModel
|
57 |
+
import torch
|
58 |
+
import json
|
59 |
+
import os
|
60 |
+
from huggingface_hub import hf_hub_download
|
61 |
+
|
62 |
+
|
63 |
+
repo_id = "sams-tom/multimodal-auv-bathy-bnn-classifier"
|
64 |
+
model_subfolder = "unimodal-bathy-bnn"
|
65 |
+
|
66 |
+
# Load the BNN prior parameters that were used during training/conversion.
|
67 |
+
# These are essential for understanding the model's Bayesian properties.
|
68 |
+
bnn_params_path = hf_hub_download(repo_id=repo_id, filename=os.path.join(model_subfolder, "bnn_params.json"))
|
69 |
+
with open(bnn_params_path, "r") as f:
|
70 |
+
const_bnn_prior_parameters = json.load(f)
|
71 |
+
print(f"Loaded BNN Prior Parameters: {const_bnn_prior_parameters}")
|
72 |
+
|
73 |
+
# Load the model directly using AutoModel, specifying the subfolder.
|
74 |
+
# trust_remote_code=True is crucial because your model uses custom classes (ResNet50Custom etc.)
|
75 |
+
# which are defined in the 'model_definitions.py' file uploaded to the root of the repository.
|
76 |
+
model = AutoModel.from_pretrained(repo_id, subfolder=model_subfolder, trust_remote_code=True)
|
77 |
+
model.eval() # Set to evaluation mode
|
78 |
+
|
79 |
+
# Example inference with dummy bathymetry data
|
80 |
+
# Adjust dimensions (batch size, channels, height, width) based on your actual data
|
81 |
+
dummy_bathy_input = torch.randn(1, 3, 224, 224) # Example: (Batch, Channels, Height, Width)
|
82 |
+
|
83 |
+
with torch.no_grad():
|
84 |
+
outputs = model(dummy_bathy_input)
|
85 |
+
probabilities = torch.softmax(outputs, dim=-1) # Get class probabilities
|
86 |
+
predicted_class = torch.argmax(probabilities, dim=-1) # Get predicted class index
|
87 |
+
|
88 |
+
print(f"Output logits: {outputs}")
|
89 |
+
print(f"Predicted class probabilities: {probabilities}")
|
90 |
+
print(f"Predicted class index: {predicted_class.item()}")
|