Performs tagging of image and videos based on various taggers
Project description
Media Tagger
Problem statement
When analyzing large amount of creatives of any nature (being images and videos) it might be challenging to quickly and reliably understand their content and gain insights.
Solution
media-tagger performs tagging of image and videos based on various taggers
- simply provide a path to your media files and
media-taggerwill do the rest.
Deliverable (implementation)
media-tagger is implemented as a:
- library - Use it in your projects with a help of
media_tagging.tagger.create_taggerfunction. - CLI tool -
media-taggertool is available to be used in the terminal. - HTTP endpoint -
media-taggercan be easily exposed as HTTP endpoint. - Langchain tool - integrated
media-taggerinto your Langchain applications.
Deployment
Prerequisites
- Python 3.11+
- A GCP project with billing account attached
- Video Intelligence API and Vision API enabled.
- API key to access to access Google Gemini.
-
Once you created API key export it as an environmental variable
export GOOGLE_API_KEY=<YOUR_API_KEY_HERE>
-
Installation
Install media-tagger with pip install media-tagging[all] command.
Alternatively you can install subsets of media-tagging library:
media-tagging[api]- tagging videos and images with Google Cloud APIs.media-tagging[image-api]- only for tagging images.media-tagging[video-api]- only for tagging videos.
media-tagging[llm]- tagging videos and images with LLMs.media-tagging[base-llm]- only for tagging images with llms.media-tagging[google-genai]- only for tagging images via Gemini.media-tagging[google-vertexai]- only for tagging videos via Gemini.
Usage
Tagging media
This section is focused on using
media-taggeras a CLI tool. Check library, http endpoint, langchain tool sections to learn more.
Once media-tagger is installed you can call it:
media-tagger ACTION MEDIA_PATHs \
--media-type <MEDIA_TYPE> \
--tagger <TAGGER_TYPE> \
--db-uri=<CONNECTION_STRING> \
--writer <WRITER_TYPE> \
--output <OUTPUT_FILE_NAME>
where:
ACTION- eithertagordescribe.MEDIA_PATHs- names of files for tagging (can be urls).<MEDIA_TYPE>- type of media (YOUTUBE_VIDEO, VIDEO, IMAGE).<TAGGER_TYPE>- name of tagger, supported options.
Tagger can be customized via
tagger.option=valuesyntax. I.e. if you want to request a specific number of tags you can add--tagger.n-tags=100CLI flag.
<CONNECTION_STRING>- Optional connection string to the database with tagging results (i.e.sqlite:///tagging.db). If this parameter is set make sure that DB exists.
To create an empty Sqlite DB execute
touch database.db.
<WRITER_TYPE>- writer identifier (check available options at garf-io library).<OUTPUT_FILE_NAME>- name of the file to store results of tagging (by defaulttagging_results).
Supported taggers
| identifier | supported media types | tagging output | options |
|---|---|---|---|
google-cloud |
image, video |
tag |
n-tags=10 |
langchain |
image, video |
tag, description |
n-tags=10, tags=tag1,tag2,tag3 |
gemini |
image, video, youtube_video |
tag, description |
n-tags=10 |
langchainandgeminitaggers can usecustom-promptparameter to adjust built-in prompts.
Loading tagging results
If you want to import tags to be used later, you can use media-loader utility.
media-loader PATH_TO_FILE \
--media-type <MEDIA_TYPE> \
--loader <LOADER_TYPE> \
--db-uri=<CONNECTION_STRING> \
--action <ACTION>
where:
<MEDIA_TYPE>- type of media (YOUTUBE_VIDEO, VIDEO, IMAGE).
For YouTube file uploads specify YOUTUBE_VIDEO type.
<LOADER_TYPE>- name of loader, currently onlyfileis supported (data are saved to CSV).
Loader can be customized via
loader.option=valuesyntax. I.e. if you want to change the default column name with media tags are located you can specify--loader.tag_name=new_column_nameCLI flag.
<CONNECTION_STRING>- Connection string to the database with tagging results (i.e.sqlite:///tagging.db). If this parameter is set make sure that DB exists.
To create an empty Sqlite DB execute
touch database.db.
ACTION- eithertagordescribe.
If loading tagging results with file loader, the CSV file should contains the following columns:
media_url- location of medium (can be remote or local).tag- column that contains name of a tag.score- column that contains prominence of a tag in the media.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file media_tagging-1.1.0.post1.tar.gz.
File metadata
- Download URL: media_tagging-1.1.0.post1.tar.gz
- Upload date:
- Size: 28.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7eaecc0b85098780c0deb2ea5586a2a89b6145e26c14f7a7738f9d9048883edf
|
|
| MD5 |
be5be6afbdc8579bd666efe4a1fb1e02
|
|
| BLAKE2b-256 |
365a7e98e5f1967229444d58f59d2c43f69bfb94600922cd7246990ab5b786e7
|
File details
Details for the file media_tagging-1.1.0.post1-py3-none-any.whl.
File metadata
- Download URL: media_tagging-1.1.0.post1-py3-none-any.whl
- Upload date:
- Size: 44.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
242ea3bc056be88deb7a21372ec09e1ebc23ae7f9fd76cf6d9eab7aaebe20b94
|
|
| MD5 |
bb801cab3d66f0959c6d32a6e8a7096c
|
|
| BLAKE2b-256 |
f88cca2968f7f4892c781744ea126df24dea37b07b4036ce850799ba14cd3e9b
|