- Introduction
- Collaborators
- Installation
- Usage
- Project Structure
- Data Loading
- Model Training
- Evaluation
- License
VideoNetClassification is a project focused on classifying videos using a Recurrent Neural Network (RNN). This project leverages TensorFlow and TensorFlow Hub for model building and training. It uses the UCF101 dataset, a popular action recognition dataset.
- Yahia Ehab
- Mariam Amr
- Mohamed Khaled
To install the required dependencies, you can use the following commands:
pip install imageio
pip install opencv-python
pip install git+https://github.com/tensorflow/docs- Clone the repository.
- Install the required dependencies as mentioned above.
- Run the
notebook.ipynbnotebook to train and evaluate the model.
notebook.ipynb: The main Jupyter Notebook containing all the code for data loading, preprocessing, model training, and evaluation.
The UCF101 dataset is used in this project. The dataset is loaded and preprocessed using various helper functions. Videos are downloaded and their frames are extracted and resized.
An RNN model is created using Keras. The training process involves:
- Extracting features from video frames using a pre-trained CNN.
- Training the RNN model with the extracted features.
-
Feature Extraction:
base_model = tf.keras.applications.InceptionV3(weights='imagenet', include_top=False, pooling='avg') video_features = [] for video in video_frames: video_features.append(base_model.predict(video))
-
Data Preparation:
split = int(0.8 * len(video_features)) train, test = video_features[:split], video_features[split:] train_labels, test_labels = labels[:split], labels[split:]
-
Label Encoding:
from tensorflow.keras.utils import to_categorical from sklearn.preprocessing import LabelEncoder label_encoder = LabelEncoder() train_labels_encoded = label_encoder.fit_transform(train_labels) train_labels_onehot = to_categorical(train_labels_encoded, num_of_classes) test_labels_encoded = label_encoder.fit_transform(test_labels) test_labels_onehot = to_categorical(test_labels_encoded, num_of_classes)
-
Model Creation and Training:
from keras.models import Sequential from keras.layers import SimpleRNN, Dense rnn_model = Sequential() rnn_model.add(SimpleRNN(50, input_shape=(sequence_length, 2048))) rnn_model.add(Dense(num_of_classes, activation="softmax")) rnn_model.compile(loss="categorical_crossentropy", optimizer="adam", metrics=["accuracy"]) rnn_model.fit(x=train, y=train_labels_onehot, epochs=15, batch_size=64, validation_split=0.2)
The trained model is evaluated using the test dataset:
evaluation = rnn_model.evaluate(x=test, y=test_labels_onehot)
print("Evaluation results:", evaluation)This project was given and managed by the GIU