This project is a deep learning-based image classification model designed to identify different types of eye diseases from images. The model is built using TensorFlow and Keras and trained on an image dataset of eye conditions.
- Convolutional Neural Network (CNN) model implementation
- Uses TensorFlow and Keras for deep learning
- Image preprocessing with ImageDataGenerator
- Supports categorical classification for multiple eye disease categories
- Model evaluation and visualization of predictions
The dataset used in this project is located at:
/kaggle/input/eye-dataset/Eye dataset
The dataset contains multiple classes of eye diseases, and images are stored in directories corresponding to their labels.
To use this project, ensure you have the following dependencies installed:
pip install tensorflow numpy matplotlib
The CNN model consists of:
- Conv2D Layers: Feature extraction through convolutional layers
- MaxPooling2D Layers: Reducing spatial dimensions to prevent overfitting
- Flatten Layer: Converts feature maps into a single-dimensional vector
- Dense Layers: Fully connected layers for classification
The model is compiled with categorical cross-entropy loss and Adam optimizer. The training is performed using fit()
with a validation set.
model.fit(train_generator, validation_data=validation_generator, epochs=10)
After training, the model can be evaluated using:
loss, accuracy = model.evaluate(validation_generator)
print(f"Validation Accuracy: {accuracy*100:.2f}%")
The gercek_deger
function allows prediction on new images:
def gercek_deger(image_path, model, class_indices):
img = load_img(image_path, target_size=(150, 150))
img_array = img_to_array(img) / 255.0
img_array = np.expand_dims(img_array, axis=0)
prediction = model.predict(img_array)
predicted_class = np.argmax(prediction)
class_labels = {v: k for k, v in class_indices.items()}
predicted_label = class_labels[predicted_class]
plt.imshow(img)
plt.title(f"Prediction: {predicted_label}")
plt.axis("off")
plt.show()
The trained model is saved as image_classifier.h5
and can be loaded using:
from tensorflow.keras.models import load_model
model = load_model("image_classifier.h5")
- Implement transfer learning with pre-trained models (e.g., VGG16, ResNet)
- Expand dataset with additional eye disease images
- Develop a web or mobile application for real-time diagnosis
This project is open-source and available under the MIT License.
For questions or contributions, please open an issue on GitHub.