Video-Stimmungsanalyse mit CLIP und CLAP
Jetzt führst du die Emotionsanalyse der Werbeanzeige durch, die du zuvor mit CLIP/CLAP vorbereitet hast. Für eine multimodale Emotionsklassifikation kombinierst du die Vorhersagen dieser Modelle über den Mittelwert (bekannt als late fusion).
Das Video (video) und das zugehörige Audio (audio_sample), die du zuvor erstellt hast, sind weiterhin verfügbar:

Eine Liste von Emotionen wurde als emotions geladen.
Diese Übung ist Teil des Kurses
Multimodale Modelle mit Hugging Face
Anleitung zur Übung
- Erstelle eine Audio-Klassifizierungs-Pipeline für
zero-shot-audio-classificationmit dem Modelllaion/clap-htsat-unfused. - Erstelle eine Bild-Klassifizierungs-Pipeline für
zero-shot-image-classificationmit dem Modellopenai/clip-vit-base-patch32(eine kleinere Variante von dem, was wir im Video verwendet haben). - Verwende die Bildklassifizierungs-Pipeline, um Vorhersagen für jedes Bild im Video zu erzeugen.
- Verwende die Audioklassifizierungs-Pipeline, um Vorhersagen für den
audio_samplezu erzeugen.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Make an audio classifier pipeline
audio_classifier = ____(model="____", task="____")
# Make an image classifier pipeline
image_classifier = ____(model="____", task="____")
# Create emotion scores for each video frame
predictions = image_classifier(video, candidate_labels=emotions)
scores = [
{l['label']: l['score'] for l in prediction}
for prediction in predictions
]
avg_image_scores = {emotion: sum([s[emotion] for s in scores])/len(scores) for emotion in emotions}
# Make audio scores
audio_scores = ____(____, candidate_labels=____)
audio_scores = {l['label']: l['score'] for l in audio_scores}
multimodal_scores = {emotion: (avg_image_scores[emotion] + audio_scores[emotion])/2 for emotion in emotions}
print(f"Multimodal scores: {multimodal_scores}")