sams-tom commited on
Commit
daccf0e
·
verified ·
1 Parent(s): 7939ea7

Create README.md

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