Views
No views yet
| Metric | Score |
|---|---|
| Accuracy | 98.96% |
| F1-Score (Macro) | 0.97 |
| Precision | 0.97 |
| Recall | 0.97 |
confusion_matrix_final.png in files for detailed analysis)| ID | Species | F1 Score | ID | Species | F1 Score |
|---|---|---|---|---|---|
| 1 | Bangus | 0.99 | 21 | Knifefish | 1.00 |
| 2 | Big Head Carp | 1.00 | 22 | Long-Snouted Pipefish | 1.00 |
| 3 | Black Sea Sprat | 1.00 | 23 | Mosquito Fish | 0.99 |
| 4 | Black Spotted Barb | 1.00 | 24 | Mudfish | 0.91 |
| 5 | Catfish | 0.98 | 25 | Mullet | 0.97 |
| 6 | Climbing Perch | 0.97 | 26 | Pangasius | 0.97 |
| 7 | Fourfinger Threadfin | 1.00 | 27 | Perch | 0.98 |
| 8 | Freshwater Eel | 0.99 | 28 | Red Mullet | 1.00 |
| 9 | Gilt-Head Bream | 1.00 | 29 | Red Sea Bream | 1.00 |
| 10 | Glass Perchlet | 0.98 | 30 | Scat Fish | 1.00 |
| 11 | Goby | 0.98 | 31 | Sea Bass | 1.00 |
| 12 | Gold Fish | 1.00 | 32 | Shrimp | 1.00 |
| 13 | Gourami | 1.00 | 33 | Silver Barb | 0.98 |
| 14 | Grass Carp | 0.98 | 34 | Silver Carp | 1.00 |
| 15 | Green Spotted Puffer | 0.98 | 35 | Silver Perch | 0.98 |
| 16 | Hourse Mackerel | 1.00 | 36 | Snakehead | 0.97 |
| 17 | Indian Carp | 0.98 | 37 | Striped Red Mullet | 1.00 |
| 18 | Indo-Pacific Tarpon | 1.00 | 38 | Tenpounder | 0.97 |
| 19 | Jaguar Gapote | 1.00 | 39 | Tilapia | 0.98 |
| 20 | Janitor Fish | 1.00 | 40 | Trout | 1.00 |
✨ Plus: For any species not listed above, the integrated BioCLIP-2 model provides Zero-Shot Classification capabilities.
ConvNeXt Tiny to prioritize inference speed and efficiency. While optimized, it may have lower capacity compared to "Huge" or "Large" architectures in extremely complex scenes.Rembg to remove noise (25% probability during augmentation).LR=1e-3) for 6 epochs.1e-5 (To preserve feature extraction)1e-4 (To adapt to new classes)1import torch
2from torchvision import models, transforms
3from PIL import Image
4
5# 1. Define Class Names (40 Classes)
6class_names = [
7 'Bangus', 'Big Head Carp', 'Black Sea Sprat', 'Black Spotted Barb', 'Catfish',
8 'Climbing Perch', 'Fourfinger Threadfin', 'Freshwater Eel', 'Gilt-Head Bream',
9 'Glass Perchlet', 'Goby', 'Gold Fish', 'Gourami', 'Grass Carp',
10 'Green Spotted Puffer', 'Hourse Mackerel', 'Indian Carp', 'Indo-Pacific Tarpon',
11 'Jaguar Gapote', 'Janitor Fish', 'KnifeFish', 'Long-Snouted Pipefish',
12 'Mosquito Fish', 'Mudfish', 'Mullet', 'Pangasius', 'Perch', 'Red Mullet',
13 'Red Sea Bream', 'Scat Fish', 'Sea Bass', 'Shrimp', 'Silver Barb',
14 'Silver Carp', 'Silver Perch', 'Snakehead', 'Striped Red Mullet',
15 'Tenpounder', 'Tilapia', 'Trout'
16]
17
18# 2. Load Architecture
19model = models.convnext_tiny()
20model.classifier[2] = torch.nn.Linear(model.classifier[2].in_features, 40)
21
22# 3. Load Weights
23# Ensure 'balik_modeli_final.pth' is downloaded locally
24weights_path = "balik_modeli_final.pth"
25model.load_state_dict(torch.load(weights_path, map_location=torch.device('cpu')))
26model.eval()
27
28# 4. Inference Function
29def predict_image(image_path):
30 transform = transforms.Compose([
31 transforms.Resize((224, 224)),
32 transforms.ToTensor(),
33 transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
34 ])
35
36 try:
37 img = Image.open(image_path).convert('RGB')
38 img_tensor = transform(img).unsqueeze(0)
39
40 with torch.no_grad():
41 outputs = model(img_tensor)
42 probs = torch.nn.functional.softmax(outputs, dim=1)
43 score, predicted = torch.max(probs, 1)
44
45 return {
46 "class": class_names[predicted.item()],
47 "confidence": float(score.item())
48 }
49 except Exception as e:
50 return str(e)
51
52# Example Usage:
53# result = predict_image("test_fish.jpg")
54# print(f"Predicted: {result['class']} ({result['confidence']:.2%})")