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

Add multimodal model support #931

Merged
merged 165 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
1217a0a
initial commit
RaynorChavez Aug 12, 2024
8067291
import Modalities from s2_inference
RaynorChavez Aug 12, 2024
fce6bfa
Merge branch 'mainline' into raynor/multimodal_models
RaynorChavez Aug 12, 2024
3750b86
import numpy
RaynorChavez Aug 12, 2024
81f5bc2
add abstraction for choosing encoder, fix bugs, infer modality
RaynorChavez Aug 12, 2024
27f5f18
add support for existing models, fix modealities always being treated…
RaynorChavez Aug 12, 2024
3121db9
fix call to _encode_without_cache
RaynorChavez Aug 13, 2024
893d2c7
change references to image_repo to content_repo, draft extract frames…
RaynorChavez Aug 13, 2024
28b3568
add languagebind to model registry, change image_repo test to content…
RaynorChavez Aug 13, 2024
b9a5017
languagebind helpers and classes
RaynorChavez Aug 13, 2024
2caa666
Merge branch 'mainline' into raynor/multimodal_models
RaynorChavez Aug 15, 2024
f97fdbc
preliminary load languagebind and encoders
RaynorChavez Aug 15, 2024
8514b1f
update requirements
RaynorChavez Aug 15, 2024
c22f0b0
update requirements
RaynorChavez Aug 15, 2024
c2b89ca
update requirements
RaynorChavez Aug 15, 2024
3a6c4dc
update requirements
RaynorChavez Aug 15, 2024
b732626
fix registry
RaynorChavez Aug 15, 2024
e6192ee
remove MultimodalPointer
RaynorChavez Aug 15, 2024
f8eb0fd
change requirements
RaynorChavez Aug 15, 2024
b74e72f
change requirements
RaynorChavez Aug 15, 2024
78ec4ba
Merge branch 'mainline' into raynor/multimodal_models
RaynorChavez Aug 18, 2024
1cb410f
add video and audio support in tensor search - initial commit
RaynorChavez Aug 18, 2024
a7eacf5
bump typing-extensions from 4.5.0 to 4.8.0
RaynorChavez Aug 18, 2024
1206deb
relax pytorchvideo requirement
RaynorChavez Aug 18, 2024
a669b0a
revert to torch==1.13.1
RaynorChavez Aug 18, 2024
50f4003
fix
RaynorChavez Aug 18, 2024
e098e20
revert to torch==1.12.1
RaynorChavez Aug 18, 2024
6dea0dd
relax peft requirement
RaynorChavez Aug 18, 2024
f9ac58f
upgrade to torch==1.13.1
RaynorChavez Aug 18, 2024
df569a7
add torchaudio to requirements
RaynorChavez Aug 18, 2024
18f8f05
some bug fixes
RaynorChavez Aug 19, 2024
060eb65
add initial implementation for unstructured support
RaynorChavez Aug 19, 2024
25ad9ec
remove therman and depth helper files, add media filesize lookahead l…
RaynorChavez Aug 19, 2024
6579e91
readd helper functions for depth and thermal
RaynorChavez Aug 19, 2024
8648d56
some bug fixes
RaynorChavez Aug 19, 2024
5275265
print debugs
RaynorChavez Aug 20, 2024
a92589a
working languagebind image inference
RaynorChavez Aug 20, 2024
c497349
fix text encoder logic for languagebind
RaynorChavez Aug 21, 2024
480aa61
last attempt at streaming and chunking for now
RaynorChavez Aug 21, 2024
91dba28
working video and audio add docs structured. non streaming
RaynorChavez Aug 21, 2024
7b320f1
streaming logic
RaynorChavez Aug 21, 2024
3cb3565
remove redundant multimodal loader calls
RaynorChavez Aug 21, 2024
6f8d49d
add video_chunk_length into registry and as user configurable during …
RaynorChavez Aug 21, 2024
4b7813b
add working support for unstructured add documents
RaynorChavez Aug 21, 2024
3b4b083
more efficient fetch_file_metadata
RaynorChavez Aug 22, 2024
f39639a
correct streaming logic (better duration estimation, use ffmpeg to fe…
RaynorChavez Aug 22, 2024
d74a2fa
modify tensor search add unstructured to include better chunk descrip…
RaynorChavez Aug 22, 2024
4c2aaf9
remove redundant last chunk of size overlap, add failsafe temp file d…
RaynorChavez Aug 22, 2024
5374135
claenup and add 'treatUrlsAndPointersAsMedia' and audeio and video p…
RaynorChavez Aug 22, 2024
03d4e0c
add infer modality in multimodal fields
RaynorChavez Aug 22, 2024
65ee7d9
attempt at fixing multimodal fields
RaynorChavez Aug 22, 2024
9dc9591
initial implementation of working embed
RaynorChavez Aug 22, 2024
cd46898
debug embed implementation for video and audio
RaynorChavez Aug 22, 2024
7baaac7
fix bug in multimodal fields for audio and video
RaynorChavez Aug 22, 2024
9408377
wrap languagebind inputs with to_device
RaynorChavez Aug 22, 2024
f4f4e32
fix backward compatibility errors
RaynorChavez Aug 23, 2024
0c467ce
Merge branch 'mainline' into raynor/multimodal_models
RaynorChavez Aug 23, 2024
cb3e4e2
add packages to requirements.dev
RaynorChavez Aug 23, 2024
b27061b
updated requirements
RaynorChavez Aug 23, 2024
f8d5e15
update requirements
RaynorChavez Aug 23, 2024
b4ca956
loosen torchaudio
RaynorChavez Aug 23, 2024
62772b7
upgrade protobuf to 5.27.2
RaynorChavez Aug 23, 2024
e111b84
change requirements
RaynorChavez Aug 23, 2024
f1923ef
set protobuf==3.20.0
RaynorChavez Aug 23, 2024
8a8d2be
remove protobuf
RaynorChavez Aug 23, 2024
55d6adb
copying dev requirements over to nondev for now
RaynorChavez Aug 23, 2024
8b7bbf8
add device debug statements
RaynorChavez Aug 23, 2024
c03a0bb
restore
RaynorChavez Aug 23, 2024
be52eb1
remove import ffmpeg
RaynorChavez Aug 23, 2024
2df2bd5
add default value for video and audo preprocessing in marqo_index
RaynorChavez Aug 23, 2024
a31f7a1
bug
RaynorChavez Aug 23, 2024
f987bdb
print debug
RaynorChavez Aug 23, 2024
490246b
add_docs and embed tests and fix embed
RaynorChavez Aug 23, 2024
d668363
change download logic to use existing download_image_from_url
RaynorChavez Aug 24, 2024
4a36b4e
add certificate in add_docs
RaynorChavez Aug 24, 2024
bd8f4e1
Error out if model is not multimodal and attempts to add video or audio
RaynorChavez Aug 24, 2024
320799a
add ffmpeg in requirements and in environment
RaynorChavez Aug 24, 2024
6ce4442
more efficient fetch_file_metadata
RaynorChavez Aug 24, 2024
6d04340
new tests, refactor, and move languagebind cache_dir to standard loca…
RaynorChavez Aug 24, 2024
18fd2d4
remove cache_dir from MultimodalModelProperties
RaynorChavez Aug 24, 2024
3d43ad5
fix get_tokenizer cache_dir variable
RaynorChavez Aug 24, 2024
70ecc3b
fix some requirements
RaynorChavez Aug 25, 2024
192d5b6
restore peft specific git repo
RaynorChavez Aug 25, 2024
a27dd27
refactor
RaynorChavez Aug 25, 2024
cdc6ece
change largemodel unit tests machine to g6.2xlarge
RaynorChavez Aug 25, 2024
1f0d4ed
Raynor/multimodal models reduce reqs (#946)
RaynorChavez Aug 26, 2024
b9b1bf0
restore optimum==1.20.0
RaynorChavez Aug 26, 2024
f389a4c
cleanup main requirements.txt file
RaynorChavez Aug 26, 2024
fbf1aee
skip languagebind tests if on GPU
RaynorChavez Aug 26, 2024
2e9f53c
add selective loading of languagebind models permutations
RaynorChavez Aug 26, 2024
335a65b
fix text tokenizer model path and video model name
RaynorChavez Aug 26, 2024
0e81b03
copy .dev.txt into .txt
RaynorChavez Aug 27, 2024
450fea3
fix nonetype model image
RaynorChavez Aug 27, 2024
b43b495
cleanup abstraction a bit
RaynorChavez Aug 27, 2024
593efcc
cleanup
RaynorChavez Aug 27, 2024
d3f7c09
Fix Audio and Video text Tokenizer return
RaynorChavez Aug 27, 2024
b5596d4
add MARQO_MEDIA_DOWNLOAD_THREAD_COUNT env var
RaynorChavez Aug 27, 2024
72acab5
possible memory optimizations
RaynorChavez Aug 27, 2024
54c8906
remove deletion of content repo
RaynorChavez Aug 27, 2024
b2ee5c8
comment out print statements
RaynorChavez Aug 27, 2024
67a2c1a
limit download threads for languagebind
RaynorChavez Aug 28, 2024
e3f36a5
edit log to reflect lower media download thread count
RaynorChavez Aug 28, 2024
a1f2f1e
marqo-image to 28, minibatches for processing video/audio, replace an…
RaynorChavez Aug 29, 2024
70aceeb
add torchaudio to requirements
RaynorChavez Aug 29, 2024
6e1698f
restore languagebind requirements
RaynorChavez Aug 29, 2024
331586f
restore base image to 20
RaynorChavez Aug 29, 2024
31f5b24
requirements
RaynorChavez Aug 29, 2024
0d93786
revert to docker 20
RaynorChavez Aug 29, 2024
44ccc72
print statement
RaynorChavez Aug 29, 2024
180398e
Merge branch 'mainline' into raynor/multimodal_models
RaynorChavez Aug 29, 2024
1e67105
disable minibatches for video/audio
RaynorChavez Aug 29, 2024
6bc9413
cleanup, change video only model name, add error if add image in non-…
RaynorChavez Aug 29, 2024
1ef8bc6
fix check
RaynorChavez Aug 29, 2024
71a2dbf
move tensore to cuda before vectorise call
RaynorChavez Aug 29, 2024
df6f020
Update base image to 29, remove video download limit of 5
RaynorChavez Aug 29, 2024
4b1b4ff
change default value and equalize last chunk length
RaynorChavez Sep 2, 2024
7671728
add test for chunking start-end time logic
RaynorChavez Sep 2, 2024
7620975
implementing vector averaging in multimodal docs
RaynorChavez Sep 3, 2024
d42aeba
initial implementation of embedding normalization
RaynorChavez Sep 3, 2024
f88fcbb
Merge branch 'mainline' into raynor/multimodal_models
RaynorChavez Sep 3, 2024
5b0c2ce
fix invalid media url error not showing
RaynorChavez Sep 3, 2024
debe5c2
various bug fixes
RaynorChavez Sep 3, 2024
9b70efe
improve image modality detection and fix one test
RaynorChavez Sep 4, 2024
9449dbd
fallback to python-magic
RaynorChavez Sep 4, 2024
70ef116
installl libmagic in github runners and cleanup
RaynorChavez Sep 4, 2024
813f78c
change libmagic installation check command
RaynorChavez Sep 4, 2024
41f443b
new tests for infer_modality
RaynorChavez Sep 4, 2024
0fc622b
add test for ensuring image url is embedded as image and not as text
RaynorChavez Sep 4, 2024
803738e
fix test_image_url_is_embedded_as_image_not_text
RaynorChavez Sep 4, 2024
da1d608
unskip one test
RaynorChavez Sep 4, 2024
e0efca9
add eva-decord to main requirements file
RaynorChavez Sep 5, 2024
638f400
add decord to main requirements and remove eva-decord
RaynorChavez Sep 5, 2024
d8af865
cleanup
RaynorChavez Sep 5, 2024
91d2801
move decord to under if statement
RaynorChavez Sep 5, 2024
a2a1574
remove decord from requirements
RaynorChavez Sep 5, 2024
09522ac
cleanup and addressing some comments
RaynorChavez Sep 5, 2024
215af4b
fix get_content_vector
RaynorChavez Sep 5, 2024
a15759f
fix one test
RaynorChavez Sep 5, 2024
d3cd3d7
new unit tests for infer_modality
RaynorChavez Sep 5, 2024
8767fb2
new tests for multimodal field embed and partial update to ensure ima…
RaynorChavez Sep 6, 2024
e300897
fix test
RaynorChavez Sep 6, 2024
a043aae
fix tensor_rearch reversion
RaynorChavez Sep 6, 2024
7fe1ff4
Merge branch 'mainline' into raynor/multimodal_models
RaynorChavez Sep 6, 2024
736e89a
rename files not util
RaynorChavez Sep 6, 2024
52ab8d9
add default threadcount for languagebind, new env var, error invalid …
RaynorChavez Sep 6, 2024
1a5d8c2
cleanup and addressing comments
RaynorChavez Sep 8, 2024
cca032a
reformat code
RaynorChavez Sep 8, 2024
8aa7ee2
fix error message
RaynorChavez Sep 8, 2024
cd3b568
patch threadcounts
RaynorChavez Sep 8, 2024
039b578
patch
RaynorChavez Sep 8, 2024
bbb54e0
patch
RaynorChavez Sep 9, 2024
6826205
patch media threads
RaynorChavez Sep 9, 2024
67f13ad
change chunk start end
RaynorChavez Sep 9, 2024
5933cc5
fix
RaynorChavez Sep 9, 2024
ec3b8fc
fix unstructured use_existing_tensors
RaynorChavez Sep 9, 2024
eaa33eb
modify media download threads logic
RaynorChavez Sep 9, 2024
f092d83
include webp and validate_url
RaynorChavez Sep 9, 2024
8344ce8
switch to validate_url in infer_modality
RaynorChavez Sep 9, 2024
80b4c10
Change exception capture to ffmpeg and change download condition
RaynorChavez Sep 9, 2024
dffcb3c
add test for threaded download media logic
RaynorChavez Sep 9, 2024
84f2f1a
remove main from new test
RaynorChavez Sep 9, 2024
e9d6f94
Merge branch 'mainline' into raynor/multimodal_models
RaynorChavez Sep 9, 2024
4b0d6d4
uncomment error
RaynorChavez Sep 9, 2024
03d9664
pass exception and add noindex condition
RaynorChavez Sep 9, 2024
973ae02
change condtion order
RaynorChavez Sep 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/marqo/s2_inference/clip_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ def download_image_from_url(image_path: str, image_download_headers: dict, timeo

try:
encoded_url = encode_url(image_path)
print(f"encoded url: {encoded_url}")
except UnicodeEncodeError as e:
print(f"error: {e}")
raise ImageDownloadError(f"Marqo encountered an error when downloading the image url {image_path}. "
f"The url could not be encoded properly. Original error: {e}")
buffer = BytesIO()
Expand Down
Empty file.
45 changes: 44 additions & 1 deletion src/marqo/s2_inference/model_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1932,6 +1932,45 @@ def _get_onnx_clip_properties() -> Dict:
}
return ONNX_CLIP_MODEL_PROPERTIES

def _get_languagebind_properties() -> Dict:
LANGUAGEBIND_MODEL_PROPERTIES = {
'LanguageBind_Video_V1.5_FT': {
"name": "LanguageBind_Video_V1.5_FT",
"dimensions": 768,
"type": "languagebind",
"loader": "languagebind",
"supported_modalities": ["video", "text"],
},
'LanguageBind_Audio_FT': {
"name": "LanguageBind_Audio_FT",
"dimensions": 768,
"type": "languagebind",
"loader": "languagebind",
"supported_modalities": ["audio", "text"],
},
'LanguageBind_Image': {
"name": "LanguageBind_Image",
"dimensions": 768,
"type": "languagebind",
"loader": "languagebind",
"supported_modalities": ["image", "text"],
},
'LanguageBind_Depth': {
"name": "LanguageBind_Depth",
"dimensions": 768,
"type": "languagebind",
"loader": "languagebind",
"supported_modalities": ["depth", "text"],
},
'LanguageBind_Thermal': {
"name": "LanguageBind_Thermal",
"dimensions": 768,
"type": "languagebind",
"loader": "languagebind",
"supported_modalities": ["thermal", "text"],
},
}
return LANGUAGEBIND_MODEL_PROPERTIES

def _get_fp16_clip_properties() -> Dict:
FP16_CLIP_MODEL_PROPERTIES = {
Expand Down Expand Up @@ -2008,7 +2047,9 @@ def _get_model_load_mappings() -> Dict:
"fp16_clip": FP16_CLIP,
'random':Random,
'hf':HF_MODEL,
"no_model": NO_MODEL}
"no_model": NO_MODEL,
#"languagebind": LANGUAGEBIND,
RaynorChavez marked this conversation as resolved.
Show resolved Hide resolved
}

def load_model_properties() -> Dict:
# also truncate the name if not already
Expand All @@ -2026,6 +2067,7 @@ def load_model_properties() -> Dict:
multilingual_clip_model_properties = get_multilingual_clip_properties()
fp16_clip_model_properties = _get_fp16_clip_properties()
no_model_properties = _get_no_model_properties()
#languagebind_model_properties = _get_languagebind_properties()

# combine the above dicts
model_properties = dict(clip_model_properties.items())
Expand All @@ -2039,6 +2081,7 @@ def load_model_properties() -> Dict:
model_properties.update(multilingual_clip_model_properties)
model_properties.update(fp16_clip_model_properties)
model_properties.update(no_model_properties)
#model_properties.update(languagebind_model_properties)


all_properties = dict()
Expand Down
Loading
Loading