Image embeddings and audio captions

Image embeddings and audio captions

Image embeddings and audio captions

This month we launched an iteration on two of our assortment exploration instruments — our video search and works explorer.

These iterations got here out of a meet and greet we had with the Oxford University Visual Geometry Group whereas chatting about our machine studying explorations and their Wise2 video search engine.

They talked about utilizing OpenCLIP to generate picture embeddings to check related photographs, and CLAP to explain what an audio observe appeared like to search out issues like a canine barking.

We’re very excited to strive Wise2 on our assortment movies, however whereas we get that challenge organised we thought it is perhaps good to prototype audio captions and picture embeddings in XOS (our museum working system).

ACMI video search — now with audio descriptions

What does this video sound like?

That’s the query that Microsoft’s CLAP algorithm makes an attempt to reply — so we requested it precisely that each 100 frames of video.

First we use ffmpeg to separate up the video’s audio observe into segments:

segment_number = 0
segment_start = 0

whereas segment_start < audio_length * 1000:
segment_path_name = f'{output_dir}/{video_file_name}_segment_{segment_number}.wav'
command = [
'ffmpeg',
'-y',
'-i', audio_file_path,
'-ss', str(segment_start / 1000),
'-t', str(segment_duration / 1000),
segment_path_name
]
subprocess.run(command, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT, examine=True)
segments.append(segment_path_name)
segment_number += 1
segment_start += segment_duration

Then we generate captions for every phase utilizing CLAP:

# Every sample_frequency (default 100) frames let's predict what's in it
for index, audio_file_path in enumerate(audio_file_paths):
captions = self.mannequin.generate_caption([audio_file_path])
predictions = []
for caption in captions:
predictions.append({
'prediction': caption,
})

seconds = index * self.sample_frequency * fps / 1000
self.predictions.append({
'timestamp': seconds,
'predictions': predictions,
})
print(f'Prediction at {index * self.sample_frequency} ({seconds:.1f} secs): {predictions}')

The output appears to be like like this:

Prediction at 100 (1.8 secs): [{'prediction': 'A radio station is playing a radio station. '}]
Prediction at 200 (3.6 secs): [{'prediction': 'Water is flowing through a stream and splashing in the water. '}]
Prediction at 300 (5.4 secs): [{'prediction': 'The wind is blowing and a car is driving by. '}]]

One of the quirks of this mannequin is that it recognises background noise as A radio station is taking part in a radio station. So we’ll have to preserve that in thoughts when presenting this information, maybe suppressing that output if there are extra false positives than precise positives of radio stations in our movies.

We stored the identical information format for the output, which meant that indexing these audio captions for Elasticsearch didn’t want any code adjustments. This additionally meant minimal updates had been essential so as to add this to our web site video search.

if search_type == 'audioDescription':
area = 'classification.captions.clap.predictions.prediction'
A screencast of the video search by audio description

Try it out for your self: acmi.web.au/movies/

Code: github.com/ACMILabs/video-search

HI-FI News

by way of Machine Learning on Medium https://ift.tt/3EHY872

October 1, 2024 at 02:55AM