Vision Language Transformer(ViLT)로 VQA 수행하기
이제 멀티모달 생성에 직접 도전해 볼 시간이에요. 먼저 Visual Question-Answering(VQA)부터 시작해 볼게요. dandelin/vilt-b32-finetuned-vqa 모델을 사용해 다음 이미지에서 신호등의 색을 판별해 보세요:

전처리기(processor), 모델(model), 그리고 이미지(image)는 미리 로드되어 있어요.
이 연습은 강의의 일부입니다
Hugging Face로 배우는 멀티모달 모델
연습 안내
text프롬프트와image를 전처리하세요.- 모델에서 정답 토큰을 생성해
outputs에 할당하세요. - 출력 logits를 사용해 신뢰도가 가장 높은 정답의 ID를 찾으세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
text = "What color is the traffic light?"
# Preprocess the text prompt and image
encoding = ____(____, ____, return_tensors="pt")
# Generate the answer tokens
outputs = ____
# Find the ID of the answer with the highest confidence
idx = outputs.logits.____
print("Predicted answer:", model.config.id2label[idx])