Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semantic Search for Events #8998

Closed
wants to merge 32 commits into from
Closed

Conversation

hunterjm
Copy link
Contributor

Implementation for #8980

Still a work in progress, but far enough along to play around with if interested. I still need to implement a way to keep the Events database and the vector database in sync and add missing historical events to the vector database on startup.

NickM-27 and others added 15 commits December 13, 2023 06:13
…shear#8673)

* Generate low res low fps previews for recordings viewer

* Make sure previews end on the hour

* Fix durations and decrase keyframe interval to ensure smooth scrubbing

* Ensure minimized resolution is compatible with yuv

* Add ability to configure preview quality

* Fix

* Clean up previews more efficiently

* Use iterator
* Add external sub label to timeline

* Include icon

* Update timeline.py

Co-authored-by: Sergey Krashevich <svk@svk.su>

* Formatting

---------

Co-authored-by: Sergey Krashevich <svk@svk.su>
)

* Write a low resolution low fps stream from decoded frames (blakeblackshear#8673)

* Generate low res low fps previews for recordings viewer

* Make sure previews end on the hour

* Fix durations and decrase keyframe interval to ensure smooth scrubbing

* Ensure minimized resolution is compatible with yuv

* Add ability to configure preview quality

* Fix

* Clean up previews more efficiently

* Use iterator

* Ensure final frame in preview is not duplicated

* initial react/ts framework

* fix gitignore glob excluding ts files

* ignore folders in web-new

* SWRConfig changes for swr 2.x

* use frigateConfig type in websocket handlers

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
* remove rtmp from python

* remove rtmp from nginx

* remove rtmp from docs

* fix test for missing role
* Add config editor to new webUI and fix double scroll

* Address review comments and enable light theme for vscode
…akeblackshear#8895)

* Add support for review grid

* Cleanup reloading on focus

* Adjust timeline api to include metadata and before

* Be more efficient about getting info

* Adjust to new data format

* Cleanup types

* Cleanup text

* Transition to history

* Cleanup

* remove old web implementations

* Cleanup
* Add table and oveview components

* Add toooltips for cards

* Add storage

* Undo
* Use constant aspect ratio for review grid

* Add infinite scrolling

* Don't have horizontal scrolling

* Handle autoplay for mobile

* Load more efficiently
* Add support for live views

* Lint fixes

* Fix width

* Fix lint

* Cleanup hooks
* Playback recording when clicking on review item

* Add timeline overlay selector

* Lint fixes

* Lint fixes

* Set video plays inline

* Stop autoplay on open

* Reverse order

* Improve autoplay performance

* Remove chromecast icon by default

* Improve margin and remove lazy image loading to reduce jumping

* Fix root margin for mobile

* Fix scrolling behavior

* Fix width
* Show camera dashboard

* Cleanup

* Cleanup

* Cleanup

* Cleanup

* fix

* Fix input color

* Show recent events on dashboard
* fixup build

* swap frontends
@hunterjm
Copy link
Contributor Author

And yes, I know that I added the frontend to the old web - but the new frontend only uses timeline for now, and it does not have enough detail to perform this type of search, or filters implemented at this point in time.

@hunterjm
Copy link
Contributor Author

hunterjm commented Dec 19, 2023

Implementation is mostly done at this point. I implemented the frontend in web-old because it was further along (and less work) than trying something in the new UI.

For the new UI, what do you think about a search bar at the top that is available on every page? When searched, it shows a styled dropdown of matching events allowing for additional filtering, downloading, or opening in the recordings/timeline viewer.

Examples

Search for "man with brown hair and beard"

Most results from description
image

Search for "golfers"

Most results from description
image

Search for "black and white dog"

Clicked "Find Similar" and returned image search results
image

docker/main/Dockerfile Outdated Show resolved Hide resolved
@hunterjm
Copy link
Contributor Author

I just installed this on my parent's instance without configuring Gemini. Just using the CLIP model gets some pretty decent results:

Example 1

Search Term: "chevy bolt"
image

Example 2:

Search Term: "package delivery"
Filtered to the day of 12/15
Requested similar images to the first result shown in the screenshot
image

@hunterjm
Copy link
Contributor Author

I've updated the docs and have been running this in production for a couple of days. I think it's ready for review now.

@hunterjm hunterjm marked this pull request as ready for review December 20, 2023 05:44
docs/docs/integrations/api.md Outdated Show resolved Hide resolved
@@ -337,6 +342,13 @@ def cleanup_timeline_db(db: SqliteExtDatabase) -> None:

migrate_db.close()

def init_embeddings(self) -> None:
self.embeddings: Optional[Embeddings] = None
Copy link
Sponsor Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all of these new services I think it would be good to only run them if this has been enabled in the config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the case with the client. The init method will return a ValueError if semantic_search is not enabled and self.embeddings will remain None. See: https://github.com/blakeblackshear/frigate/pull/8998/files#diff-a87fb799a0f5537bd6fb9049628a14131fb21e8bc2f0fc21363d664bb6aff7feR50-R51

@@ -584,19 +597,26 @@ def start_timeline_processor(self) -> None:
)
self.timeline_processor.start()

def start_embeddings_processor(self) -> None:
self.embeddings_processor = EmbeddingProcessor(
Copy link
Sponsor Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, only start the service if enabled in the config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Sponsor Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I figured that was the case but think it might be better to have it explicit in this file vs the implicit behavior. Not a big deal though

frigate/events/cleanup.py Outdated Show resolved Hide resolved
@skrashevich
Copy link
Contributor

you seen this project?

@hunterjm
Copy link
Contributor Author

you seen this project?

I had not until now. GPT-4 Vision can be integrated this way relatively easy as well, or that project can be updated to submit the summary as a description directly to Frigate and have it indexed and searchable.

I like the use of multiple image frames representing a fuller context, but wanted to keep it relatively simple for the first implementation.

@NickM-27
Copy link
Sponsor Collaborator

@blakeblackshear need to reopen this with new base branch just fyi

@blakeblackshear blakeblackshear changed the base branch from 0.14 to dev January 31, 2024 13:25
@hunterjm
Copy link
Contributor Author

hunterjm commented Jun 3, 2024

Closing this for now. New PR will be forthcoming targeting the new UI for 0.14 after discussing with @NickM-27 and @blakeblackshear.

@hunterjm hunterjm closed this Jun 3, 2024
@hunterjm hunterjm mentioned this pull request Jun 12, 2024
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants