Getting Started#

Part 1: Install EVA#

EVA supports Python (versions >= 3.7). To install EVA, we recommend using the pip package manager:

pip install evadb

Launch EVA server#

EVA is based on a client-server architecture. To launch the EVA server, run the following command on the terminal:

eva_server &

Part 2: Start a Jupyter Notebook Client#

Here is an illustrative Jupyter notebook focusing on MNIST image classification using EVA. The notebook works on Google Colab.

Connect to the EVA server#

To connect to the EVA server in the notebook, use the following Python code:

# allow nested asyncio calls for client to connect with server
import nest_asyncio

# hostname and port of the server where EVA is running
connection = connect(host = '', port = 5432)

# cursor allows the notebook client to send queries to the server
cursor = connection.cursor()

Load video for analysis#

Download the MNIST video.

!wget -nc

Use the LOAD statement is used to load a video onto a table in EVA server.

cursor.execute('LOAD FILE "mnist.mp4" INTO MNISTVideoTable;')
response = cursor.fetch_all()

Run a query#

Run a query over the video to retrieve the output of the MNIST CNN function that is included in EVA as a built-in user-defined function (UDF).

cursor.execute("""SELECT id, MnistCNN(data).label
                FROM MNISTVideoTable
                WHERE id < 5;""")
response = cursor.fetch_all()

That’s it! You can now run more complex queries.

Part 3: Register an user-defined function (UDF)#

User-defined functions allow us to combine SQL with deep learning models. These functions can wrap around deep learning models.

Download an user-defined function for classifying MNIST images.

!wget -nc
cursor.execute("""CREATE UDF IF NOT EXISTS MnistCNN
                  INPUT  (data NDARRAY (3, 28, 28))
                  OUTPUT (label TEXT(2))
                  TYPE  Classification
                  IMPL  '';
response = cursor.fetch_all()

Run a more interesting query using the newly registered UDF#

cursor.execute("""SELECT data, MnistCNN(data).label
                  FROM MNISTVideoTable
                  WHERE id = 30;""")
response = cursor.fetch_all()

Visualize the Output#

The output of the query is visualized in the notebook.

Part 5: Start a Command Line Client#

Besides the notebook interface, EVA also exports a command line interface for querying the server. This interface allows for quick querying from the terminal:

>>> eva_client
eva=# LOAD FILE "mnist.mp4" INTO MNISTVid;
@status: ResponseStatus.SUCCESS

0 Video successfully added at location: mnist.p4
@query_time: 0.045

eva=# SELECT id, data FROM MNISTVid WHERE id < 1000;
@status: ResponseStatus.SUCCESS
    0          0             [[[ 0 2 0]\n [0 0 0]\n...
    1          1             [[[ 2 2 0]\n [1 1 0]\n...
    2          2             [[[ 2 2 0]\n [1 2 2]\n...
    ..       ...
    997        997           [[[ 0 2 0]\n [0 0 0]\n...
    998        998           [[[ 0 2 0]\n [0 0 0]\n...
    999        999           [[[ 2 2 0]\n [1 1 0]\n...

[1000 rows x 2 columns]
@query_time: 0.216

eva=# exit