-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_setup.py
More file actions
147 lines (126 loc) · 4.42 KB
/
verify_setup.py
File metadata and controls
147 lines (126 loc) · 4.42 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
145
146
147
#!/usr/bin/env python
"""
Verification script for Plant Disease Detection Application
This script checks the environment, dependencies, and file structure
"""
import os
import sys
import importlib
import subprocess
from pathlib import Path
def check_python_version():
"""Check if Python version is compatible"""
print(f"Python version: {sys.version}")
if sys.version_info < (3, 8):
print("❌ Python version should be 3.8 or higher")
return False
print("✅ Python version OK")
return True
def check_dependencies():
"""Check if all required packages are installed"""
required_packages = [
"flask", "flask_sqlalchemy", "pillow", "torch", "torchvision",
"pandas", "numpy", "python-dotenv"
]
all_installed = True
for package in required_packages:
try:
# Normalize package name for import
import_name = package.replace("-", "_")
importlib.import_module(import_name)
print(f"✅ {package} is installed")
except ImportError:
print(f"❌ {package} is not installed")
all_installed = False
return all_installed
def check_file_structure():
"""Check if all required files and directories exist"""
required_files = [
"run.py",
"requirements.txt",
"README.md",
"data/disease_info.csv",
"data/supplement_info.csv",
"models/plant_disease_model_1.pt"
]
required_dirs = [
"app",
"data",
"models",
"static",
"static/css",
"static/js",
"static/uploads",
"templates"
]
all_files_exist = True
all_dirs_exist = True
# Check files
for file_path in required_files:
if not os.path.isfile(file_path):
print(f"❌ File missing: {file_path}")
all_files_exist = False
else:
print(f"✅ File exists: {file_path}")
# Check directories
for dir_path in required_dirs:
if not os.path.isdir(dir_path):
print(f"❌ Directory missing: {dir_path}")
all_dirs_exist = False
else:
print(f"✅ Directory exists: {dir_path}")
return all_files_exist and all_dirs_exist
def check_model_compatibility():
"""Check if the model file is compatible with installed torch version"""
if not os.path.isfile("models/plant_disease_model_1.pt"):
print("❌ Model file is missing")
return False
try:
import torch
# Attempt to load model - this will fail if incompatible
print("Testing model loading...")
model = torch.load("models/plant_disease_model_1.pt", map_location=torch.device('cpu'))
print(f"✅ Model can be loaded with torch {torch.__version__}")
return True
except Exception as e:
print(f"❌ Model loading failed: {str(e)}")
return False
def main():
"""Main verification function"""
print("\n" + "="*50)
print("Plant Disease Detection Application - Verification")
print("="*50 + "\n")
# Path checks
print("Current directory:", os.getcwd())
print("\n" + "-"*50)
print("CHECKING PYTHON ENVIRONMENT")
print("-"*50)
python_ok = check_python_version()
print("\n" + "-"*50)
print("CHECKING DEPENDENCIES")
print("-"*50)
deps_ok = check_dependencies()
print("\n" + "-"*50)
print("CHECKING FILE STRUCTURE")
print("-"*50)
files_ok = check_file_structure()
print("\n" + "-"*50)
print("CHECKING MODEL COMPATIBILITY")
print("-"*50)
model_ok = check_model_compatibility()
# Summary
print("\n" + "="*50)
print("VERIFICATION SUMMARY")
print("="*50)
print(f"Python environment: {'✅ OK' if python_ok else '❌ Issues found'}")
print(f"Dependencies: {'✅ OK' if deps_ok else '❌ Issues found'}")
print(f"File structure: {'✅ OK' if files_ok else '❌ Issues found'}")
print(f"Model compatibility: {'✅ OK' if model_ok else '❌ Issues found'}")
if all([python_ok, deps_ok, files_ok, model_ok]):
print("\n✅ All checks passed! The application should run correctly.")
print("Run 'python run.py' to start the application.")
else:
print("\n❌ Some checks failed. Please fix the issues before running the application.")
print("See the HELP.md file for troubleshooting information.")
if __name__ == "__main__":
main()