Update README.md
Browse files
README.md
CHANGED
|
@@ -18,6 +18,18 @@ This model is designed to classify grapevine leaves as either "healthy" or affec
|
|
| 18 |
- **Model Architecture**: Convolutional Neural Network (CNN)
|
| 19 |
- **Input**: Images of grape leaves
|
| 20 |
- **Output**: Binary classification indicating whether the leaf is healthy or affected by Esca
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
## Dataset
|
| 23 |
|
|
|
|
| 18 |
- **Model Architecture**: Convolutional Neural Network (CNN)
|
| 19 |
- **Input**: Images of grape leaves
|
| 20 |
- **Output**: Binary classification indicating whether the leaf is healthy or affected by Esca
|
| 21 |
+
- **focal_loss function**:
|
| 22 |
+
```
|
| 23 |
+
def focal_loss(gamma=2., alpha=0.25):
|
| 24 |
+
def focal_loss_fixed(y_true, y_pred):
|
| 25 |
+
y_true = tf.cast(y_true, tf.float32)
|
| 26 |
+
y_pred = tf.clip_by_value(y_pred, tf.keras.backend.epsilon(), 1 - tf.keras.backend.epsilon())
|
| 27 |
+
alpha_t = y_true * alpha + (tf.ones_like(y_true) - y_true) * (1 - alpha)
|
| 28 |
+
p_t = y_true * y_pred + (tf.ones_like(y_true) - y_true) * (tf.ones_like(y_true) - y_pred)
|
| 29 |
+
focal_loss_value = -alpha_t * tf.math.pow((tf.ones_like(y_true) - p_t), gamma) * tf.math.log(p_t)
|
| 30 |
+
return tf.reduce_mean(focal_loss_value)
|
| 31 |
+
return focal_loss_fixed
|
| 32 |
+
```
|
| 33 |
|
| 34 |
## Dataset
|
| 35 |
|