NimurAI commited on
Commit
1745d01
Β·
verified Β·
1 Parent(s): 0b6fa7c

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +142 -0
README.md ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: pytorch
3
+ tags:
4
+ - anomaly-detection
5
+ - autoencoder
6
+ - plant-detection
7
+ - computer-vision
8
+ - pytorch-lightning
9
+ datasets:
10
+ - custom-plant-dataset
11
+ metrics:
12
+ - reconstruction-error
13
+ - threshold-based-classification
14
+ pipeline_tag: image-classification
15
+ ---
16
+
17
+ # plant-detector
18
+
19
+ ## Model Description
20
+
21
+ Convolutional Autoencoder for plant anomaly detection
22
+
23
+ This is a Convolutional Autoencoder (CAE) trained for plant anomaly detection. The model learns to reconstruct plant images and detects anomalies based on reconstruction error.
24
+
25
+ ## Model Details
26
+
27
+ - **Model Type**: Convolutional Autoencoder
28
+ - **Framework**: PyTorch Lightning
29
+ - **Task**: Anomaly Detection / Plant Classification
30
+ - **Input**: RGB images (224x224)
31
+ - **Output**: Reconstruction + anomaly score
32
+
33
+ ## Training Details
34
+
35
+ - **Architecture**: Encoder-Decoder with skip connections
36
+ - **Loss Function**: Mean Squared Error (MSE)
37
+ - **Optimizer**: AdamW
38
+ - **Learning Rate**: 0.0001
39
+ - **Batch Size**: 32
40
+ - **Epochs**: N/A
41
+ - **Dataset Size**: N/A images
42
+
43
+ ## Performance Metrics
44
+
45
+ - **Validation Loss**: N/A
46
+ - **Threshold**: 0.5687
47
+ - **Mean Reconstruction Error**: N/A
48
+ - **Std Reconstruction Error**: N/A
49
+ - **Anomaly Rate**: N/A
50
+
51
+ ## Normalization Statistics
52
+
53
+ The model expects input images to be normalized with:
54
+ - **Mean**: [0.4682, 0.4865, 0.3050]
55
+ - **Std**: [0.2064, 0.1995, 0.1961]
56
+
57
+ ## Usage
58
+
59
+ ### PyTorch Lightning Checkpoint
60
+
61
+ ```python
62
+ from annomallyDet.models.lit_models.lit_cae import LitCAE
63
+
64
+ # Load the model
65
+ model = LitCAE.load_from_checkpoint("plant_anomaly_detector.ckpt")
66
+ model.eval()
67
+
68
+ # Make prediction
69
+ reconstruction_error = model.get_reconstruction_error(input_tensor)
70
+ is_anomaly = reconstruction_error > 0.5687
71
+ ```
72
+
73
+ ### Mobile Deployment (TorchScript Lite)
74
+
75
+ ```python
76
+ import torch
77
+
78
+ # Load mobile model
79
+ model = torch.jit.load("plant_anomaly_detector.ptl")
80
+ reconstruction = model(input_tensor)
81
+
82
+ # Calculate reconstruction error
83
+ error = torch.mean((input_tensor - reconstruction) ** 2)
84
+ is_anomaly = error > 0.5687
85
+ ```
86
+
87
+ ### Flutter Integration
88
+
89
+ See the included `flutter_integration_example.dart` for complete Flutter app integration using `flutter_pytorch_lite`.
90
+
91
+ ## Files Included
92
+
93
+ - `plant_anomaly_detector.ckpt`: PyTorch Lightning checkpoint
94
+ - `plant_anomaly_detector.ptl`: TorchScript Lite model for mobile deployment
95
+ - `config.json`: Model configuration and metadata
96
+ - `flutter_integration_example.dart`: Flutter integration example
97
+ - `normalization_stats.json`: Dataset normalization statistics
98
+
99
+ ## Model Architecture
100
+
101
+ ```
102
+ Input (3, 224, 224)
103
+ ↓
104
+ Encoder: Conv2d β†’ BatchNorm β†’ LeakyReLU β†’ Dropout
105
+ [32, 64, 128, 256] channels
106
+ ↓
107
+ Latent Space (128 dimensions)
108
+ ↓
109
+ Decoder: ConvTranspose2d β†’ BatchNorm β†’ LeakyReLU β†’ Dropout
110
+ [256, 128, 64, 32] channels
111
+ ↓
112
+ Output (3, 224, 224)
113
+ ```
114
+
115
+ ## Anomaly Detection Logic
116
+
117
+ 1. **Training**: Model learns to reconstruct normal plant images
118
+ 2. **Inference**: Calculate reconstruction error (MSE)
119
+ 3. **Decision**: If error > threshold β†’ Anomaly (not a plant)
120
+ 4. **Confidence**: Distance from threshold indicates confidence
121
+
122
+ ## Limitations
123
+
124
+ - Trained specifically on plant images
125
+ - Performance depends on similarity to training data
126
+ - May struggle with novel plant species not in training set
127
+ - Threshold may need adjustment for different use cases
128
+
129
+ ## Citation
130
+
131
+ ```bibtex
132
+ @misc{plant_anomaly_detector,
133
+ title={Plant Anomaly Detection using Convolutional Autoencoder},
134
+ author={Your Name},
135
+ year={2024},
136
+ howpublished={\url{https://huggingface.co/YOUR_USERNAME/plant-detector}},
137
+ }
138
+ ```
139
+
140
+ ## License
141
+
142
+ [Specify your license here]