MOVIE ANALYSIS#

Run on Google Colab View source on GitHub Download notebook

Start EVA Server#

We are reusing the start server notebook for launching the EVA server

!wget -nc "https://raw.githubusercontent.com/georgia-tech-db/eva/master/tutorials/00-start-eva-server.ipynb"
%run 00-start-eva-server.ipynb
cursor = connect_to_server()
File '00-start-eva-server.ipynb' already there; not retrieving.

[  -z "$(lsof -ti:5432)" ] || kill -9 $(lsof -ti:5432)
nohup eva_server > eva.log 2>&1 &

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Note: you may need to restart the kernel to use updated packages.

Video Files#

getting some video files to test

# A video of a happy person
!wget -nc https://www.dropbox.com/s/gzfhwmib7u804zy/defhappy.mp4

# Adding Emotion detection
!wget -nc https://raw.githubusercontent.com/georgia-tech-db/eva/master/eva/udfs/emotion_detector.py

# Adding Face Detector
!wget -nc https://raw.githubusercontent.com/georgia-tech-db/eva/master/eva/udfs/face_detector.py
--2022-12-18 17:39:00--  https://www.dropbox.com/s/gzfhwmib7u804zy/defhappy.mp4
Resolving www.dropbox.com (www.dropbox.com)... 162.125.81.18, 2620:100:6031:18::a27d:5112, 2620:100:6031:18::a27d:5112
Connecting to www.dropbox.com (www.dropbox.com)|162.125.81.18|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: /s/raw/gzfhwmib7u804zy/defhappy.mp4 [following]
--2022-12-18 17:39:01--  https://www.dropbox.com/s/raw/gzfhwmib7u804zy/defhappy.mp4
Reusing existing connection to www.dropbox.com:443.
HTTP request sent, awaiting response... 302 Found
Location: https://ucb58bff9e7d777abe691a3f348e.dl.dropboxusercontent.com/cd/0/inline/By2iKFVkUD3x0OHMwghV_MV6nSCjCnh4YRS-cszetNJ6rXf297c4p7hWMYcPPDTsFRIfr0QuuxUCP-9v2n7PNsTLUnXmA80kwVJqV2g2V1Rgslztow1Eb7cQr1RoolH5EgEz_ZePK45F2yHPaFuKzauAFxrDKY11qLQCFPqoh3W1fw/file# [following]
--2022-12-18 17:39:02--  https://ucb58bff9e7d777abe691a3f348e.dl.dropboxusercontent.com/cd/0/inline/By2iKFVkUD3x0OHMwghV_MV6nSCjCnh4YRS-cszetNJ6rXf297c4p7hWMYcPPDTsFRIfr0QuuxUCP-9v2n7PNsTLUnXmA80kwVJqV2g2V1Rgslztow1Eb7cQr1RoolH5EgEz_ZePK45F2yHPaFuKzauAFxrDKY11qLQCFPqoh3W1fw/file
Resolving ucb58bff9e7d777abe691a3f348e.dl.dropboxusercontent.com (ucb58bff9e7d777abe691a3f348e.dl.dropboxusercontent.com)... 162.125.81.15, 2620:100:6031:15::a27d:510f
Connecting to ucb58bff9e7d777abe691a3f348e.dl.dropboxusercontent.com (ucb58bff9e7d777abe691a3f348e.dl.dropboxusercontent.com)|162.125.81.15|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2699034 (2.6M) [video/mp4]
Saving to: 'defhappy.mp4'

defhappy.mp4        100%[===================>]   2.57M   817KB/s    in 3.2s    

2022-12-18 17:39:07 (817 KB/s) - 'defhappy.mp4' saved [2699034/2699034]

--2022-12-18 17:39:07--  https://raw.githubusercontent.com/georgia-tech-db/eva/master/eva/udfs/emotion_detector.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.111.133, 185.199.109.133, 185.199.108.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.111.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5378 (5.3K) [text/plain]
Saving to: 'emotion_detector.py'

emotion_detector.py 100%[===================>]   5.25K  --.-KB/s    in 0.004s  

2022-12-18 17:39:07 (1.42 MB/s) - 'emotion_detector.py' saved [5378/5378]

--2022-12-18 17:39:07--  https://raw.githubusercontent.com/georgia-tech-db/eva/master/eva/udfs/face_detector.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.111.133, 185.199.109.133, 185.199.108.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.111.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2552 (2.5K) [text/plain]
Saving to: 'face_detector.py'

face_detector.py    100%[===================>]   2.49K  --.-KB/s    in 0s      

2022-12-18 17:39:08 (29.4 MB/s) - 'face_detector.py' saved [2552/2552]

Adding the video file to EVADB for analysis#

cursor.execute('DROP TABLE HAPPY')
response = cursor.fetch_all()
print(response)
cursor.execute('LOAD VIDEO "defhappy.mp4" INTO HAPPY')
response = cursor.fetch_all()
print(response)
@status: ResponseStatus.FAIL
@batch: 
 None
@error: Table: HAPPY does not exist
@status: ResponseStatus.SUCCESS
@batch: 
                            0
0  Number of loaded VIDEO: 1
@query_time: 0.08177788800003327

Visualize Video#

from IPython.display import Video
Video("defhappy.mp4", height=450, width=800, embed=True)