This project presents a complete deep learning pipeline for automatic classification of 20 types of fruits and vegetables from images. Two models were designed and evaluated: a Custom Convolutional Neural Network (CNN) built entirely from scratch without any pre-trained weights, and a MobileNetV2 model using Transfer Learning pre-trained on the ImageNet dataset. The dataset was obtained from Kaggle and contains approximately 1,700 training images across 20 selected classes — 10 fruits and 10 vegetables. The pipeline includes data preprocessing (contrast enhancement, histogram equalization, normalization), exploratory data analysis, data augmentation, regularization techniques (Dropout and Batch Normalization), and full model evaluation using accuracy, precision, recall, F1-score, and confusion matrix. The Custom CNN achieved 81.41% test accuracy while MobileNetV2 achieved approximately 97%, demonstrating the significant advantage of transfer learning over training from scratch on small datasets. A Streamlit web application was developed to allow real-time image prediction using either model, along with a full visual comparison between the two approaches.
يقدم هذا المشروع خط أنابيب تعلم عميق متكامل للتصنيف التلقائي لـ 20 نوعاً من الفواكه والخضروات من الصور. تم تصميم نموذجين وتقييمهما: شبكة عصبية تلافيفية مخصصة (CNN) مبنية بالكامل من الصفر بدون أي أوزان مدربة مسبقاً، ونموذج MobileNetV2 باستخدام التعلم المنقول المدرب مسبقاً على مجموعة بيانات ImageNet. تم الحصول على مجموعة البيانات من Kaggle وتحتوي على حوالي 1,700 صورة تدريبية موزعة على 20 فئة مختارة — 10 فواكه و10 خضروات. يشمل خط الأنابيب المعالجة المسبقة للبيانات (تحسين التباين، معادلة الرسم البياني، التطبيع)، والتحليل الاستكشافي للبيانات، وتوسيع البيانات، وتقنيات التنظيم (Dropout وBatch Normalization)، والتقييم الكامل للنموذج باستخدام الدقة والضبط والاستدعاء ودرجة F1 ومصفوفة الارتباك. حققت شبكة CNN المخصصة دقة اختبار 81.41% بينما حقق MobileNetV2 حوالي 97%، مما يُثبت الميزة الكبيرة للتعلم المنقول على التدريب من الصفر على مجموعات البيانات الصغيرة. تم تطوير تطبيق ويب باستخدام Streamlit للسماح بالتنبؤ الفوري بالصور باستخدام أي من النموذجين، إلى جانب مقارنة بصرية كاملة بين الأسلوبين.