From e678819f706686229fa23a7680b80f0903f0dbe4 Mon Sep 17 00:00:00 2001 From: kuschzzp <38914005+kuschzzp@users.noreply.github.com> Date: Thu, 28 Nov 2024 13:09:02 +0800 Subject: [PATCH] Fix RGBA error (#3707) ### What problem does this PR solve? **Passing cv_mdl.describe() is not an RGB converted image** ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- rag/app/picture.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rag/app/picture.py b/rag/app/picture.py index 8d5df5219..fb9b1e269 100644 --- a/rag/app/picture.py +++ b/rag/app/picture.py @@ -41,7 +41,10 @@ def chunk(filename, binary, tenant_id, lang, callback=None, **kwargs): try: callback(0.4, "Use CV LLM to describe the picture.") cv_mdl = LLMBundle(tenant_id, LLMType.IMAGE2TEXT, lang=lang) - ans = cv_mdl.describe(binary) + img_binary = io.BytesIO() + img.save(img_binary, format='JPEG') + img_binary.seek(0) + ans = cv_mdl.describe(img_binary.read()) callback(0.8, "CV LLM respond: %s ..." % ans[:32]) txt += "\n" + ans tokenize(doc, txt, eng)