<jupyter_start><jupyter_text>This script will read in all the images, crop them to the face, and then calculate the mean luminance.<jupyter_code>%matplotlib inline
import matplotlib.pyplot as plt

import os
from glob import glob

import numpy as np
import pandas as pd

import skimage.io as io
io.use_plugin('matplotlib')

import menpo.io as mio
from menpowidgets import visualize_images
from pathlib import Path

from tqdm import tqdm
unfam_df = pd.read_csv("/data1/famface01/analysis/encoding/12_Features/unfam_final_frame_df.csv")
unfam_df = unfam_df.ix[:,1:]
unfam_df.head()<jupyter_output><empty_output><jupyter_text>Load the images and crop to the face.<jupyter_code>from menpo.landmark import face_ibug_68_to_face_ibug_68_trimesh, face_ibug_68_to_face_ibug_68, labeller

unfam_images = []
for i,row in tqdm(unfam_df.iterrows(), total=len(unfam_df)):
    img = mio.import_image(row.fpath)
    img = img.crop_to_landmarks_proportion(0.1)
    labeller(img, 'PTS', face_ibug_68_to_face_ibug_68_trimesh)
    unfam_images.append(img)<jupyter_output>100%|██████████| 6912/6912 [03:28<00:00, 35.00it/s]<jupyter_text>Calculate the average luminance for each image.<jupyter_code>mean_lumis = np.array([ img.as_greyscale().as_vector().mean() for img in tqdm(unfam_images) ])
odf = pd.DataFrame({'vid': unfam_df.vid, 'frame': unfam_df.frame, 'luminance': mean_lumis}, columns=['vid', 'frame', 'luminance'])
odf.head()
odf.to_csv('/data1/famface01/analysis/misc/400_nnet_specificity/feats_ave_luminance.csv')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11879895561357702, 'fraction_numerical': 0.03198433420365535, 'mean_word_length': 7.026178010471204, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '328944', 'license': 'MIT', 'n_tokens_mistral': 647, 'n_tokens_neox': 608, 'n_words': 117, 'path': '400_nnet_specificity/010_luminance.ipynb', 'repo_name': 'HumanNeuroscienceLab/face_fam', 'size': '1532'}