Skip to content

Commit

Permalink
Update to MiniCPM-Llama3-V 2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
yiranyyu committed May 20, 2024
1 parent c0e39db commit 2c75097
Show file tree
Hide file tree
Showing 27 changed files with 1,929 additions and 970 deletions.
796 changes: 375 additions & 421 deletions README.md

Large diffs are not rendered by default.

773 changes: 359 additions & 414 deletions README_en.md

Large diffs are not rendered by default.

Binary file added assets/MiniCPM-Llama3-V-2.5-peformance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/gif_cases/1-4.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/gif_cases/meal_plan.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/gif_cases/ticket.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/llavabench_compare.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
176 changes: 176 additions & 0 deletions assets/minicpm-llama-v-2-5_languages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
- English
- 中文
- 한국어
- 日本語
- Deutsch
- Français
- Português
- Español
- မြန်မာဘာသာ
- ไทย
- Tiếng Việt
- Türkçe
- ܣܘܪܝܝܐ
- العربية
- हिन्दी
- বাংলা
- नेपाली
- Türkmençe
- Тоҷикӣ
- Кыргызча
- Русский
- Українська
- Беларуская
- ქართული
- Azərbaycanca
- Հայերեն
- Polski
- Lietuvių
- Eesti
- Latviešu
- Čeština
- Slovenčina
- Magyar
- Slovenščina
- Hrvatski
- Bosanski
- Crnogorski
- Српски
- Shqip
- Română
- Български
- Македонски


## 支持语言

英语

中文

韩语

日语

德语

法语

葡萄牙语

西班牙语

缅甸语

泰语

越南语

土耳其语

叙利亚语

阿拉伯语

印地语

孟加拉语

尼泊尔语

土库曼语

塔吉克语

吉尔吉斯语

俄语

乌克兰语

白俄罗斯语

格鲁吉亚语

阿塞拜疆语

亚美尼亚语

波兰语

立陶宛语

爱沙尼亚语

拉脱维亚语

捷克语

斯洛伐克语

匈牙利语

斯洛文尼亚语

克罗地亚语

波斯尼亚语

黑山语

塞尔维亚语

阿尔巴尼亚语

罗马尼亚语

保加利亚

马其顿语



## Supported Languages

English
Chinese
Korean
Japanese
German
French
Portuguese
Spanish
Burmese
Thai
Vietnamese
Turkish
Syriac
Arabic
Hindi
Bengali
Nepali
Turkmen
Tajik
Kyrgyz
Russian
Ukrainian
Belarusian
Georgian
Azerbaijani
Armenian
Polish
Lithuanian
Estonian
Latvian
Czech
Slovak
Hungarian
Slovenian
Croatian
Bosnian
Montenegrin
Serbian
Albanian
Romanian
Bulgarian
Macedonian
Binary file modified assets/minicpmv-2-peformance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/minicpmv-llama3-v2.5/case_OCR_en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/minicpmv-llama3-v2.5/case_long_img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/minicpmv-llama3-v2.5/case_markdown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/minicpmv-llama3-v2.5/cases_all.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/minicpmv-llama3-v2.5/temp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file added assets/minicpmv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,36 @@ def chat(self, input):
)
return answer

class MiniCPMV2_5:
def __init__(self, model_path) -> None:
self.model = AutoModel.from_pretrained(model_path, trust_remote_code=True).to(dtype=torch.float16)
self.tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
self.model.eval().cuda()

def chat(self, input):
try:
image = Image.open(io.BytesIO(base64.b64decode(input['image']))).convert('RGB')
except Exception as e:
return "Image decode error"

msgs = json.loads(input['question'])

answer = self.model.chat(
image=image,
msgs=msgs,
tokenizer=self.tokenizer,
sampling=True,
temperature=0.7
)
return answer


class OmniLMMChat:
def __init__(self, model_path) -> None:
if '12B' in model_path:
self.model = OmniLMM12B(model_path)
elif 'MiniCPM-Llama3-V' in model_path:
self.model = MiniCPMV2_5(model_path)
else:
self.model = OmniLMM3B(model_path)

Expand Down
Loading

0 comments on commit 2c75097

Please sign in to comment.