This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Run linear model predicting Income from Age, Gender, and their interactions. | |
| m <- lm('Income~Age*Gender',data=data) | |
| summary(m) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contrasts(data$Gender) <- c(-.5,.5) | |
| m <- lm('Income~Age*Gender',data=data) | |
| summary(m) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contrasts(data$Gender) <- contr.treatment(2) | |
| m <- lm('Income~Age*Gender',data=data) | |
| summary(m) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| m <- lm('Income~Age+Gender',data=data) | |
| summary(m) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from os.path import exists, join, basename, splitext | |
| git_repo_url = 'https://github.com/TadasBaltrusaitis/OpenFace.git' | |
| project_name = splitext(basename(git_repo_url))[0] | |
| # clone openface | |
| !git clone -q --depth 1 $git_repo_url | |
| # install new CMake becaue of CUDA10 | |
| !wget -q https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.tar.gz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from IPython.display import YouTubeVideo | |
| # Change the Youtube_ID with the link to your group's video. | |
| YOUTUBE_ID = 'XtA6FQz8BHQ' | |
| YouTubeVideo(YOUTUBE_ID) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| !rm -rf youtube.mp4 | |
| # download the youtube with the given ID | |
| !youtube-dl -f 'bestvideo[ext=mp4]' --output "youtube.%(ext)s" https://www.youtube.com/watch?v=$YOUTUBE_ID | |
| # cut the first 5 seconds | |
| !ffmpeg -y -loglevel info -i youtube.mp4 -t 10 video.mp4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # clear any previous outputs. | |
| !rm -rf processed | |
| # detect poses on the these 10 seconds. | |
| !./OpenFace/build/bin/FaceLandmarkVidMulti -f video.mp4 -out_dir processed | |
| # convert the result into MP4 | |
| !ffmpeg -y -loglevel info -i processed/video.avi output.mp4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def show_local_mp4_video(file_name, width=640, height=480): | |
| import io | |
| import base64 | |
| from IPython.display import HTML | |
| video_encoded = base64.b64encode(io.open(file_name, 'rb').read()) | |
| return HTML(data='''<video width="{0}" height="{1}" alt="test" controls> | |
| <source src="data:video/mp4;base64,{2}" type="video/mp4" /> | |
| </video>'''.format(width, height, video_encoded.decode('ascii'))) | |
| show_local_mp4_video('output.mp4', width=960, height=720) |