Mustafa5645344 commited on
Commit
4a1932f
·
verified ·
1 Parent(s): de39e2e

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +63 -7
README.md CHANGED
@@ -9,18 +9,71 @@ tags:
9
  - insect-detection
10
  - biology
11
  - agriculture
 
12
  license: mit
13
  pipeline_tag: image-classification
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  ---
15
 
16
  # Insect Classification: Vision Transformer (ViT) Model
17
 
18
- This repository contains a fine-tuned **Vision Transformer (ViT)** model (`ViTForImageClassification`) trained to classify **21 distinct insect species** with high precision for agricultural monitoring and biological biodiversity analysis.
19
 
20
- ## Supported Insect Classes (21 Classes)
21
- - `ant` (0), `aphid` (1), `bees` (2), `butterfly` (3), `caterpillar` (4), `cicada` (5), `dragonfly` (6), `grasshopper` (7), `green_lacewing` (8), `ladybug` (9), `leafhopper` (10), `mantis` (11), `mole_cricket` (12), `planthopper` (13), `rhino_beetle` (14), `rice_bug` (15), `spider` (16), `stem_borer` (17), `stink_bug` (18), `undefined` (19), `weevil` (20)
 
 
 
 
22
 
23
- ## Quick Usage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  ```python
26
  from transformers import AutoImageProcessor, AutoModelForImageClassification
@@ -38,8 +91,11 @@ inputs = processor(images=image, return_tensors="pt")
38
 
39
  with torch.no_grad():
40
  outputs = model(**inputs)
41
- logits = outputs.logits
42
- predicted_class_idx = logits.argmax(-1).item()
 
 
 
43
 
44
- print("Predicted Insect:", model.config.id2label[str(predicted_class_idx)])
45
  ```
 
9
  - insect-detection
10
  - biology
11
  - agriculture
12
+ - fine-tuned
13
  license: mit
14
  pipeline_tag: image-classification
15
+ metrics:
16
+ - accuracy
17
+ - f1
18
+ model-index:
19
+ - name: Mustafa5645344/insect-detection-vit
20
+ results:
21
+ - task:
22
+ type: image-classification
23
+ name: Insect Species Classification
24
+ dataset:
25
+ type: specifly-insect-dataset
26
+ name: Specifly 50K Insect Dataset
27
+ metrics:
28
+ - type: accuracy
29
+ value: 0.9851
30
+ name: Accuracy
31
+ - type: f1
32
+ value: 0.9858
33
+ name: F1-Score
34
  ---
35
 
36
  # Insect Classification: Vision Transformer (ViT) Model
37
 
38
+ This model is a high-accuracy fine-tuned **Vision Transformer (ViT)** (`google/vit-base-patch16-224-in21k` backbone) trained to classify **21 distinct agricultural insect pest and beneficial species**.
39
 
40
+ ## Training Hardware & Specs
41
+ - **Compute:** NVIDIA A100 Tensor Core GPU (SXM4 40GB)
42
+ - **Total Training Steps:** 16,600 iterations (20 full epochs)
43
+ - **Training Time:** 31 minutes 25 seconds
44
+ - **Base Architecture:** Vision Transformer Base (`vit-base-patch16-224`)
45
+ - **Image Resolution:** 224 x 224 px
46
 
47
+ ---
48
+
49
+ ## Evaluation Benchmark & Training History
50
+
51
+ | Epoch | Training Loss | Validation Loss | Accuracy | F1-Score |
52
+ | :---: | :---: | :---: | :---: | :---: |
53
+ | 1 | 0.3389 | 0.3206 | 97.41% | 97.57% |
54
+ | 2 | 0.1076 | 0.1481 | 97.77% | 97.91% |
55
+ | 3 | 0.0486 | 0.1073 | 97.83% | 97.95% |
56
+ | 4 | 0.0252 | 0.0999 | 98.13% | 98.18% |
57
+ | 5 | 0.0167 | 0.0784 | 98.45% | 98.51% |
58
+ | 10 | 0.0065 | 0.1190 | 98.03% | 98.12% |
59
+ | 15 | 0.0003 | 0.1093 | 98.42% | 98.50% |
60
+ | 19 | 0.0001 | 0.1151 | **98.51%** | **98.59%** |
61
+ | **20 (Final)** | **0.0001** | **0.1153** | **98.51%** | **98.58%** |
62
+
63
+ ### Top Metrics Achieved:
64
+ - **Final Top-1 Accuracy:** **98.51%**
65
+ - **Macro F1-Score:** **98.58%**
66
+ - **Minimal Training Loss:** **0.000100**
67
+
68
+ ---
69
+
70
+ ## Supported Taxa / Classes (21 Classes)
71
+
72
+ `ant`, `aphid`, `bees`, `butterfly`, `caterpillar`, `cicada`, `dragonfly`, `grasshopper`, `green_lacewing`, `ladybug`, `leafhopper`, `mantis`, `mole_cricket`, `planthopper`, `rhino_beetle`, `rice_bug`, `spider`, `stem_borer`, `stink_bug`, `undefined`, `weevil`
73
+
74
+ ---
75
+
76
+ ## Quick Inference Usage
77
 
78
  ```python
79
  from transformers import AutoImageProcessor, AutoModelForImageClassification
 
91
 
92
  with torch.no_grad():
93
  outputs = model(**inputs)
94
+ probs = torch.softmax(outputs.logits, dim=-1)
95
+ predicted_idx = outputs.logits.argmax(-1).item()
96
+
97
+ predicted_label = model.config.id2label[str(predicted_idx)]
98
+ confidence = probs[0][predicted_idx].item()
99
 
100
+ print(f"Species: {predicted_label} (Confidence: {confidence*100:.2f}%)")
101
  ```