Update README.md
Browse files
README.md
CHANGED
|
@@ -58,9 +58,7 @@ model = build_model() # Architecture defined in the `build_model` function
|
|
| 58 |
model.load_weights(model_path)
|
| 59 |
```
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
The `build_model` function defines the architecture:
|
| 64 |
|
| 65 |
```python
|
| 66 |
import tensorflow as tf
|
|
@@ -68,7 +66,6 @@ from tensorflow import keras
|
|
| 68 |
from tensorflow.keras import layers
|
| 69 |
|
| 70 |
# Global parameters for model input shape (ensure these are defined before calling build_model)
|
| 71 |
-
# Example:
|
| 72 |
# TIME_STEPS = 30
|
| 73 |
# HEIGHT = 299
|
| 74 |
# WIDTH = 299
|
|
@@ -76,22 +73,17 @@ from tensorflow.keras import layers
|
|
| 76 |
def build_model(lstm_hidden_size=256, num_classes=2, dropout_rate=0.5):
|
| 77 |
# Input shape: (batch_size, TIME_STEPS, HEIGHT, WIDTH, 3)
|
| 78 |
inputs = layers.Input(shape=(TIME_STEPS, HEIGHT, WIDTH, 3))
|
| 79 |
-
|
| 80 |
# TimeDistributed layer to apply the base model to each frame
|
| 81 |
base_model = keras.applications.Xception(weights='imagenet', include_top=False, pooling='avg')
|
| 82 |
# For inference, we don't need to set trainable, but if you plan to retrain, you can set accordingly
|
| 83 |
# base_model.trainable = False
|
| 84 |
-
|
| 85 |
# Apply TimeDistributed wrapper
|
| 86 |
x = layers.TimeDistributed(base_model)(inputs)
|
| 87 |
# x shape: (batch_size, TIME_STEPS, 2048)
|
| 88 |
-
|
| 89 |
# LSTM layer
|
| 90 |
x = layers.LSTM(lstm_hidden_size)(x)
|
| 91 |
-
|
| 92 |
x = layers.Dropout(dropout_rate)(x)
|
| 93 |
outputs = layers.Dense(num_classes, activation='softmax')(x)
|
| 94 |
-
|
| 95 |
model = keras.Model(inputs, outputs)
|
| 96 |
return model
|
| 97 |
```
|
|
|
|
| 58 |
model.load_weights(model_path)
|
| 59 |
```
|
| 60 |
|
| 61 |
+
The `build_model` function defines the architecture as:
|
|
|
|
|
|
|
| 62 |
|
| 63 |
```python
|
| 64 |
import tensorflow as tf
|
|
|
|
| 66 |
from tensorflow.keras import layers
|
| 67 |
|
| 68 |
# Global parameters for model input shape (ensure these are defined before calling build_model)
|
|
|
|
| 69 |
# TIME_STEPS = 30
|
| 70 |
# HEIGHT = 299
|
| 71 |
# WIDTH = 299
|
|
|
|
| 73 |
def build_model(lstm_hidden_size=256, num_classes=2, dropout_rate=0.5):
|
| 74 |
# Input shape: (batch_size, TIME_STEPS, HEIGHT, WIDTH, 3)
|
| 75 |
inputs = layers.Input(shape=(TIME_STEPS, HEIGHT, WIDTH, 3))
|
|
|
|
| 76 |
# TimeDistributed layer to apply the base model to each frame
|
| 77 |
base_model = keras.applications.Xception(weights='imagenet', include_top=False, pooling='avg')
|
| 78 |
# For inference, we don't need to set trainable, but if you plan to retrain, you can set accordingly
|
| 79 |
# base_model.trainable = False
|
|
|
|
| 80 |
# Apply TimeDistributed wrapper
|
| 81 |
x = layers.TimeDistributed(base_model)(inputs)
|
| 82 |
# x shape: (batch_size, TIME_STEPS, 2048)
|
|
|
|
| 83 |
# LSTM layer
|
| 84 |
x = layers.LSTM(lstm_hidden_size)(x)
|
|
|
|
| 85 |
x = layers.Dropout(dropout_rate)(x)
|
| 86 |
outputs = layers.Dense(num_classes, activation='softmax')(x)
|
|
|
|
| 87 |
model = keras.Model(inputs, outputs)
|
| 88 |
return model
|
| 89 |
```
|