File size: 2,925 Bytes
d9d9ed1
9630948
 
 
 
 
 
d9d9ed1
3ec7a30
 
d9d9ed1
 
9630948
d9d9ed1
9630948
 
 
d9d9ed1
9630948
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: DateFruitClassifierResNet50
emoji: 🌴
colorFrom: gray
colorTo: green
sdk: streamlit
app_file: src/streamlit_app.py
pinned: false
short_description: Date fruit image classifier app using ResNet50.
license: mit
---

# πŸ“¦ Date Fruit Classification using ResNet50 (Transfer Learning)

## πŸ“˜ Project Summary
This project classifies different types of date fruits using deep learning.  
Because the dataset is small and the fruits look very similar, I used **Transfer Learning with ResNet50**, a model pre-trained on ImageNet. This helped improve accuracy and reduce training time.

---

## 🎯 Goals
- Classify multiple date fruit types using images  
- Use ResNet50 with transfer learning  
- Compare model results with a CNN trained from scratch  
- Evaluate with accuracy/loss curves and classification report  
- Write a technical report (included as PDF)

---

## πŸ“Š Results

| Model | Validation Accuracy | Validation Loss | Macro F1-score |
|-------|---------------------|-----------------|----------------|
| Custom CNN (no TL) | ~90% | ~0.30 | ~0.88 |
| **ResNet50 (with TL)** | **94.22%** | **0.1842** | **0.94** |

βœ” Transfer Learning improved accuracy  
βœ” Model did not overfit  
βœ” Works well at classifying most types

---

## 🧠 Model Used

ResNet50 (ImageNet weights, frozen)
β†’ GlobalAveragePooling2D
β†’ Dense(256, relu)
β†’ Dropout(0.5)
β†’ Dense(num_classes, softmax)

yaml
Code kopieren

---

## πŸ”§ Training Settings

| Option | Value |
|--------|-------|
| Optimizer | Adam (lr = 0.001) |
| Loss | sparse_categorical_crossentropy |
| Batch Size | 16 |
| Epochs | 40 |
| Validation Split | 20% |
| Callbacks | ReduceLROnPlateau, ModelCheckpoint, EarlyStopping |

---

## πŸ“ Files

πŸ“‚ project_folder
β”‚
β”œβ”€β”€ app.py # Optional Streamlit app
β”œβ”€β”€ model_resnet50.keras # Trained model
β”œβ”€β”€ notebook.ipynb # Training notebook
β”œβ”€β”€ history_resnet50.pkl # Training history
β”œβ”€β”€ resnet50_transfer_learning_report.pdf # Full report (EN + DE)
└── README.md # This file

yaml
Code kopieren

---

## πŸš€ How to Use the Model

```python
from tensorflow.keras.models import load_model
import numpy as np
from tensorflow.keras.preprocessing import image

model = load_model('model_resnet50.keras')

img = image.load_img('test_image.jpg', target_size=(224, 224))
img_array = image.img_to_array(img)
img_array = np.expand_dims(img_array, axis=0)

prediction = model.predict(img_array)
print(prediction)
πŸ” Next Steps (Optional)
Fine-tune ResNet50 (unfreeze some layers, lower learning rate)

Add more images to improve weak classes

Try class weighting


πŸ“„ **Download Technical Report (PDF)**  
[CNN_Date_Report.pdf](./resnet50_report.pdf)

πŸ§‘β€πŸ’» Author
Enes Yamac

Deep Learning Project – Transfer Learning with ResNet50

πŸ“… November 2025

πŸ“Œ Final Note
Transfer Learning helped achieve high accuracy and reliable classification performance.