import frame_dataloader
from evaluation import legacy_load_model
from evaluation.evaluation import *
from utils.drive_manager import DriveManager

#####################################################
feature_field_size = 2048
testing_samples_per_video = 19
#####################################################
"""Managed"""
evaluate = False
generate_test = False

drive_manager = DriveManager("motion_feature_dataset")
drive_manager.download_file(
    '1O8OM6Q01az_71HdMQmWM3op1qJhfsQoI',
    "motion.zip")  # the id of the zip file contains my network

motion_model_restored = legacy_load_model(
    filepath="motion.h5",
    custom_objects={
        'sparse_categorical_cross_entropy_loss':
        sparse_categorical_cross_entropy_loss,
        "acc_top_1": acc_top_1,
        "acc_top_5": acc_top_5
    })
motion_model_restored.summary()
# xception here is a layer
# The architecture summary is
# input_image > batch_norm > xception layer
xception_rebuilt = Model(
Exemple #2
0
import frame_dataloader
from evaluation import legacy_load_model
from evaluation.evaluation import *
from utils.drive_manager import DriveManager

#####################################################
feature_field_size = 2048
testing_samples_per_video = 19
#####################################################
"""Managed"""
evaluate = False
generate_test = False

drive_manager = DriveManager("spatial_feature_dataset")
drive_manager.download_file('17O8JdvaSNJFmbvZtQPIBYNLgM9Um-znf', "spatial.zip")
spatial_model_restored = legacy_load_model(
    filepath="spatial.h5",
    custom_objects={
        'sparse_categorical_cross_entropy_loss':
        sparse_categorical_cross_entropy_loss,
        "acc_top_1": acc_top_1,
        "acc_top_5": acc_top_5
    })

spatial_model_restored.summary()

spatial_model_with_2_outputs = Model(
    spatial_model_restored.inputs,  # input image
    [layer.output for layer in spatial_model_restored.layers[-2:]
     ]  # visual features, softmax output
        "train_features_spatial.pickle")

    if len(test_spatial) == 0:
        print(
            "Please run 'generate_spatial_feature_dataset.py' and generate 'test_features_spatial.pickle'..this file will be saved to your drive in '<YOUR FOLDER:{}>/spatial_feature_dataset'"
            .format(drive_manager_spatial.personal_dfolder))
        exit()

    if len(train_spatial) == 0:
        print(
            "Please run 'generate_spatial_feature_dataset.py' and generate 'train_features_spatial.pickle'..those files will be saved to your drive in '<YOUR FOLDER:{}>/spatial_feature_dataset'"
            .format(drive_manager_spatial.personal_dfolder))
        exit()

    drive_manager_spatial.download_file(test_spatial[0]["id"],
                                        "test_features_spatial.pickle",
                                        unzip=False)

    if len(glob.glob("train_features_spatial.pickle*")) != len(train_spatial):
        drive_manager_spatial.download_files_list(train_spatial, False, False)

if is_motion:
    drive_manager_motion = DriveManager("motion_feature_dataset")

    test_motion = drive_manager_motion.search_file(
        "test_features_motion.pickle")
    train_motion = drive_manager_motion.search_file(
        "train_features_motion.pickle")

    if len(test_motion) == 0:
        print(
"""
********************************
*   Created by mohammed-alaa   *
********************************
Evaluate motion and spatial streams
"""
import frame_dataloader
from evaluation import legacy_load_model, get_batch_size
from evaluation.evaluation import *
from utils.drive_manager import DriveManager
"""
Evaluate spatial stream
"""
# download
drive_manager = DriveManager("spa-xception-adam-5e-06-imnet")
drive_manager.download_file('1djGzpxAYFvNX-UaQ7ONqDHGgnzc8clBK', "spatial.zip")

# load into ram
print("Spatial stream")
spatial_model_restored = legacy_load_model(
    filepath="spatial.h5",
    custom_objects={
        'sparse_categorical_cross_entropy_loss':
        sparse_categorical_cross_entropy_loss,
        "acc_top_1": acc_top_1,
        "acc_top_5": acc_top_5
    })
spatial_model_restored.summary()

# evaluate
_, spatial_test_loader, test_video_level_label = frame_dataloader.SpatialDataLoader(