Try to use VQAPromot node to generate prompt but got this error:
CLIPTextEncode
'list' object has no attribute 'replace'
My workflow:
I tried to review the code, and then I found that the node returns a string list, guessing it's for supporting multiple image inputs, but in the end, it wasn't processed into a single string:
def vqa_prompt(self, image, vqa_model, question):
answers = []
[vqa_processor, vqa_model, device, precision, model_name] = vqa_model
for img in image:
_img = tensor2pil(img).convert("RGB")
final_answer = question
matches = re.findall(r'\{([^}]*)\}', question)
for match in matches:
if precision == 'fp16':
inputs = vqa_processor(_img, match, return_tensors="pt").to(device, torch.float16)
else:
inputs = vqa_processor(_img, match, return_tensors="pt").to(device)
out = vqa_model.generate(**inputs)
match_answer = vqa_processor.decode(out[0], skip_special_tokens=True)
log(f'{self.NODE_NAME} Q:"{match}", A:"{match_answer}"')
final_answer = final_answer.replace("{" + match + "}", match_answer)
answers.append(final_answer)
log(f"{self.NODE_NAME} Processed.", message_type='finish')
return (answers,)
Try to use VQAPromot node to generate prompt but got this error:
My workflow:
I tried to review the code, and then I found that the node returns a string list, guessing it's for supporting multiple image inputs, but in the end, it wasn't processed into a single string:
My fix was simple:
If this fix is fine, I can submit a PR.