|
import os |
|
|
|
def main(): |
|
print("This is the main function of the utilities module.") |
|
|
|
totalFeatureCount = 0 |
|
totalJsonFileCount = 0 |
|
cnns = ['incp3', 'vgg19'] |
|
sources = ['full_movies', 'movie_shots', 'movie_trailers'] |
|
|
|
for cnn in cnns: |
|
for source in sources: |
|
print(f"- Processing CNN: {cnn}, Source: {source}") |
|
|
|
featureCount = 0 |
|
jsonFileCount = 0 |
|
|
|
rootDir = f"{source}/{cnn}" |
|
|
|
for folder in os.listdir(rootDir): |
|
movieFolder = os.path.join(rootDir, folder) |
|
if os.path.isdir(movieFolder): |
|
files = os.listdir(movieFolder) |
|
jsonFileCount += len([f for f in files if f.endswith('.json')]) |
|
|
|
for file in files: |
|
if file.endswith('.json'): |
|
jsonFilePath = os.path.join(movieFolder, file) |
|
with open(jsonFilePath, 'r') as f: |
|
data = f.read() |
|
|
|
featureCount += data.count('"frameId"') |
|
|
|
print(f"-- Found {jsonFileCount} feature packets (JSON files) in {movieFolder}") |
|
print(f"-- Found {featureCount} features embeddings in {movieFolder}") |
|
|
|
totalFeatureCount += featureCount |
|
totalJsonFileCount += jsonFileCount |
|
|
|
print(f"Total feature embeddings count: {totalFeatureCount}") |
|
print(f"Total feature packets (JSON files) count: {totalJsonFileCount}") |
|
|
|
if __name__ == "__main__": |
|
main() |