OpenBMB / MiniCPM

MiniCPM3-4B: An edge-side LLM that surpasses GPT-3.5-Turbo.
Apache License 2.0
7.16k stars 458 forks source link

The same output #56

Closed pribadihcr closed 9 months ago

pribadihcr commented 10 months ago

Hi, I tried to infer MiniCPM-V different images in loops. But got the same result.

images = ["a.jpg", "b.jpg", "c.jpg"]

for img in images:
     image = Image.open(image_path).convert('RGB')
     res, context, _ = model.chat(
            image=image,
            msgs=msgs,
            context=None,
            tokenizer=tokenizer,
            sampling=False,
            temperature=0.0
        )
     print(res)

the "res" has the same output.

THUCSTHanxu13 commented 9 months ago

please change "image = Image.open(image_path).convert('RGB')" to "image = Image.open(img).convert('RGB')"

THUCSTHanxu13 commented 9 months ago

everytime you open the file "image_path" rather than "img"

pribadihcr commented 9 months ago

@THUCSTHanxu13 ,

Sorry, the issue still exists.

images = ["a.jpg", "b.jpg", "c.jpg"]

for img in images:
     image = Image.open(img).convert('RGB')
     res, context, _ = model.chat(
            image=image,
            msgs=msgs,
            context=None,
            tokenizer=tokenizer,
            sampling=False,
            temperature=0.0
        )
     print(res)
ShengdingHu commented 9 months ago

Do you still have questions? @pribadihcr

pribadihcr commented 9 months ago
model = AutoModel.from_pretrained('openbmb/MiniCPM-V', trust_remote_code=True, cache_dir="./cache")
tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-V', trust_remote_code=True, cache_dir="./cache")

prompt = 'What is this photo about? Please answer with details.'
msgs = [{'role': 'user', 'content': prompt}]

images = ["a.jpg", "b.jpg", "c.jpg"]

for img in images:
    image = Image.open(img).convert('RGB')
    res, context, _ = model.chat(
        image=image,
        msgs=msgs,
        context=None,
        tokenizer=tokenizer,
        sampling=False,
        temperature=0.0
    )
    print(res)

@ShengdingHu, with the script above give the same output. Please double check with reproduce it. Thank you.

YuzaChongyi commented 9 months ago

@pribadihcr You should put msgs inside the for loop,because msgs are updated when called model.chat