-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_guide.py
More file actions
executable file
·144 lines (118 loc) · 4.56 KB
/
setup_guide.py
File metadata and controls
executable file
·144 lines (118 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env python3
"""
Interactive setup and usage guide for Fish Identifier AI
"""
import os
import sys
import subprocess
def print_header(text):
"""Print a formatted header"""
print("\n" + "=" * 70)
print(f" {text}")
print("=" * 70)
def print_step(number, text):
"""Print a formatted step"""
print(f"\n[Step {number}] {text}")
print("-" * 70)
def check_kaggle_setup():
"""Check if Kaggle API is configured"""
kaggle_config = os.path.expanduser("~/.kaggle/kaggle.json")
return os.path.exists(kaggle_config)
def main():
print_header("🐟 Fish Identifier AI - Interactive Setup & Guide 🤖")
print("""
This AI system identifies fish species from images using deep learning.
What this system does:
• Downloads a dataset of 9,000+ fish images (9 species)
• Trains a neural network to recognize fish species
• Makes predictions on new fish images with confidence scores
• Visualizes predictions with charts
""")
# Check environment
print_step("1/4", "Environment Check")
venv_active = hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix)
if not venv_active:
print("⚠️ Virtual environment not activated!")
print("\nPlease run:")
print(" python3 -m venv venv")
print(" source venv/bin/activate # On Windows: venv\\Scripts\\activate")
print(" pip install -r requirements.txt")
print("\nThen run this script again.")
return
else:
print("✓ Virtual environment is active")
# Check dependencies
try:
import torch
print(f"✓ PyTorch {torch.__version__} installed")
if torch.cuda.is_available():
print(f"✓ GPU available: {torch.cuda.get_device_name(0)}")
else:
print("ℹ️ Using CPU (training will be slower)")
except ImportError:
print("✗ PyTorch not installed")
print("Run: pip install -r requirements.txt")
return
# Check Kaggle
print_step("2/4", "Kaggle API Setup")
if check_kaggle_setup():
print("✓ Kaggle API configured")
else:
print("⚠️ Kaggle API not configured (required for dataset download)")
print("\nTo set up Kaggle API:")
print(" 1. Go to https://www.kaggle.com/settings/account")
print(" 2. Scroll to 'API' section")
print(" 3. Click 'Create New Token' (downloads kaggle.json)")
print(" 4. Move kaggle.json to ~/.kaggle/")
print(" 5. Set permissions: chmod 600 ~/.kaggle/kaggle.json")
print("\nYou can also manually download the dataset from:")
print(" https://www.kaggle.com/datasets/crowww/a-large-scale-fish-dataset")
# Usage options
print_step("3/4", "Choose Your Option")
print("""
A) Quick Demo (Recommended for first-time users)
└─ Downloads data, trains model, tests prediction
└─ Command: python demo.py
└─ Time: ~30-45 minutes with GPU, 2-3 hours with CPU
B) Manual Training (For customization)
└─ Step 1: python download_dataset.py
└─ Step 2: python train.py --epochs 20
└─ Step 3: python predict.py <image.jpg>
C) Quick Prediction (If model already trained)
└─ python predict.py path/to/fish_image.jpg
└─ python visualize.py path/to/fish_image.jpg
D) Batch Processing (Multiple images)
└─ python predict.py path/to/image_folder/
└─ python visualize.py path/to/image_folder/
""")
print_step("4/4", "Training Tips")
print("""
For best results:
• Use GPU if available (10x faster training)
• Start with ResNet-18 (default, better accuracy)
• Train for at least 20 epochs
• Use batch size 32-64 depending on GPU memory
• Monitor validation accuracy (saved in models/)
Advanced options:
python train.py --help # See all training options
python predict.py --help # See prediction options
python visualize.py --help # See visualization options
""")
print_header("Ready to Start!")
print("""
Quick start commands:
# Full demo (all-in-one)
python demo.py
# Or step by step:
python download_dataset.py # Download fish dataset
python train.py --epochs 20 # Train the AI model
python predict.py my_fish.jpg # Identify a fish
python visualize.py my_fish.jpg # See prediction chart
For detailed documentation, see README.md
""")
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\n\nSetup cancelled by user.")
sys.exit(0)