"In this case, we return `None` because no matches were identified."
]
}
],
"metadata": {
...
...
%% Cell type:markdown id: tags:
[](https://colab.research.google.com/github/aurelio-labs/semantic-router/blob/main/docs/08-multi-modal.ipynb) [](https://nbviewer.org/github/aurelio-labs/semantic-router/blob/main/docs/08-multi-modal.ipynb)
%% Cell type:markdown id: tags:
# Multi-Modal Routes
%% Cell type:markdown id: tags:
The Semantic Router library can also be used for detection of specific images or videos, for example the detection of **N**ot **S**hrek **F**or **W**ork (NSFW) and **S**hrek **F**or **W**ork (SFW) images as we will demonstrate in this walkthrough.
%% Cell type:markdown id: tags:
## Getting Started
%% Cell type:markdown id: tags:
We start by installing the library:
%% Cell type:code id: tags:
``` python
!pipinstall-qU \
"semantic-router[vision]==0.0.25" \
datasets==2.17.0
```
%% Cell type:markdown id: tags:
We start by downloading a multi-modal dataset, we'll be using the `aurelio-ai/shrek-detection` dataset from Hugging Face.
Now we define the `RouteLayer`. When called, the route layer will consume text (a query) and output the category (`Route`) it belongs to — to initialize a `RouteLayer` we need our `encoder` model and a list of `routes`.
%% Cell type:code id: tags:
``` python
fromsemantic_router.layerimportRouteLayer
rl=RouteLayer(encoder=encoder,routes=routes)
```
%% Cell type:markdown id: tags:
Now we can test it with _text_ to see if we hit the routes that we defined with images:
%% Cell type:code id: tags:
``` python
rl("don't you love politics?")
```
%% Cell type:code id: tags:
``` python
rl("shrek")
```
%% Cell type:code id: tags:
``` python
rl("dwayne the rock johnson")
```
%% Cell type:markdown id: tags:
Everything is being classified accurately, let's pull in some images that we haven't seen before and see if we can classify them as NSFW or SFW.