Views
No views yet
dataset/G1020/Images_Square/ (e.g., 237.jpg).backend/requirements.txtdataset/G1020/Images_Square/ (e.g., 237.jpg)1git clone https://github.com/Stalin-143/ai-eye-disease-detection.git
2cd ai-eye-disease-detection1python3.10 -m venv venv
2source venv/bin/activate # Linux/Mac
3venv\Scripts\activate # Windows
4pip install --upgrade pip1cd backend
2pip install -r requirements.txttorch==2.0.1 fails, try:pip install torch==2.0.1 torchvision==0.15.21mkdir -p backend/model
2wget https://huggingface.co/5t4l1n/ai-eye-disease-detection/resolve/main/model/best_glaucoma_model.pth -O backend/model/best_glaucoma_model.pthbackend/.env:1FLASK_ENV=development
2FLASK_DEBUG=True
3FLASK_HOST=0.0.0.0
4FLASK_PORT=5000
5MODEL_PATH=./backend/model/best_glaucoma_model.pth
6MAX_CONTENT_LENGTH=16777216
7ALLOWED_ORIGINS=http://localhost:8000MODEL_PATH with the absolute path if needed (e.g., /home/stalin/Projects/ai-eye-disease-detection/backend/model/best_glaucoma_model.pth).rm -rf __pycache__ backend/__pycache__ backend/app/__pycache__ai-eye-disease-detection/
├── backend/
│ ├── app/
│ │ ├── main.py # Flask app entry point
│ │ ├── routes/prediction.py # API endpoints for predictions
│ │ ├── utils/glaucoma_predictor.py # Model inference logic
│ ├── model/
│ │ ├── best_glaucoma_model.pth # Pre-trained model
│ ├── requirements.txt # Backend dependencies
│ ├── .env # Environment variables
├── frontend/
│ ├── index.html # Frontend UI
│ ├── script.js # Frontend JavaScript
│ ├── styles.css # Frontend styles
├── dataset/
│ ├── G1020/
│ │ ├── Images_Square/ # Retinal images (e.g., 237.jpg)
│ ├── training.ipynb # Jupyter notebook for training
├── server.py # Runs backend and frontend
├── venv/ # Virtual environment
├── backup.ipynb # Backup notebook
├── models/ # Additional models (optional)
├── README.md # Project documentation
├── requirements.txt # Root-level dependencies (optional)
├── templates/ # Flask templates (if used)1cd ai-eye-disease-detection
2source venv/bin/activate
3python server.pyhttp://localhost:5000http://localhost:8000
Expected logs:INFO:__main__:Starting Flask backend on http://localhost:5000...
Backend: DEBUG:__main__:✅ Glaucoma predictor initialized successfully!
INFO:__main__:Starting frontend HTTP server on http://localhost:8000...
INFO:__main__:Both servers started successfully!Ctrl+C.docker build -t ai-eye-disease-detection .docker build -t ai-eye-disease-detection .dataset/ directory to access images.1docker run -d \
2 -p 5000:5000 \
3 -p 8000:8000 \
4 -v $(pwd)/dataset:/app/dataset \
5 --name ai-eye-disease-container \
6 ai-eye-disease-detection1docker run -d `
2 -p 5000:5000 `
3 -p 8000:8000 `
4 -v ${PWD}/dataset:/app/dataset `
5 --name ai-eye-disease-container `
6 ai-eye-disease-detection1docker run -d ^
2 -p 5000:5000 ^
3 -p 8000:8000 ^
4 -v %CD%\dataset:/app/dataset ^
5 --name ai-eye-disease-container ^
6 ai-eye-disease-detection-v mounts the local dataset/ directory to /app/dataset in the container.dataset/ directory exists locally.1docker ps
2docker logs ai-eye-disease-containerINFO:__main__:Starting Flask backend on http://localhost:5000...
Backend: DEBUG:__main__:✅ Glaucoma predictor initialized successfully!
INFO:__main__:Starting frontend HTTP server on http://localhost:8000...curl http://localhost:5000/health{"status":"healthy","model_loaded":true}curl http://localhost:5000/api/model-info{"success":true,"data":{"model_type":"GlaucomaSeverityModel","architecture":"ResNet101 with SE Blocks",...}}curl -F "image=@dataset/G1020/Images_Square/237.jpg" -F "return_probabilities=true" http://localhost:5000/api/predict{"success":true,"data":{"cdr":0.45,"severity":"Normal","severity_description":"No significant glaucoma signs","confidence":0.95,"risk_level":"Low","probabilities":{"Normal":0.95,"Mild":0.03,"Moderate":0.01,"Severe":0.01}},"filename":"237.jpg"}http://localhost:8000 in a browser.237.jpg).dataset/G1020/Images_Square/ has labeled images.Normal/, Mild/).ls dataset/G10201source venv/bin/activate
2pip install jupyterjupyter notebook dataset/training.ipynbdataset/G1020/Images_Square/).1import torch
2import torchvision
3from torch.utils.data import DataLoader
4from torchvision import transforms
5transform = transforms.Compose([
6 transforms.Resize((224, 224)),
7 transforms.ToTensor(),
8 transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
9])
10dataset = torchvision.datasets.ImageFolder('dataset/G1020/Images_Square/', transform=transform)
11loader = DataLoader(dataset, batch_size=32, shuffle=True)
12model = torchvision.models.resnet101(pretrained=True)
13model.fc = torch.nn.Linear(model.fc.in_features, 4)
14optimizer = torch.optim.Adam(model.parameters(), lr=0.001)
15criterion = torch.nn.CrossEntropyLoss()torch.save(model.state_dict(), 'backend/model/new_glaucoma_model.pth')MODEL_PATH to the new model in backend/.env.ls backend/model/MODEL_PATH in backend/.env.curl -F "image=@dataset/G1020/Images_Square/237.jpg" -F "return_probabilities=true" http://localhost:5000/api/predictpip install torch==2.0.1 torchvision==0.15.2https://github.com/Stalin-143/ai-eye-disease-detectiongit checkout -b feature/your-featuregit commit -m "Add your feature"git push origin feature/your-feature