Downloads · 30 days
6
6% of all-time downloads
fengpeiyuan/MiniCPMV-Xray-Images-Lora
MiniCPMV-Xray-Images-Lora is a machine learning model from fengpeiyuan. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft.
- Developed by: [More Information Needed] - Funded by [optional]: [More Information Needed] - Shared by [optional]: [More Information Needed] - Model type: [More Information Needed] - Language(s) (NLP): [More Informat…
Downloads · 30 days
6
6% of all-time downloads
All-time downloads
107
Public
Repo size
49.4 MB
Likes
0
Public
Click a slice to open those files.
.pt41.5 MB · 79%
From the Hugging Face model README
Firstly, load model ``python import torch from transformers import AutoTokenizer, AutoModel
torch.manual_seed(0)
model_path = "/path/to/MiniCPM-V-2"
peft_path = "/path/to/checkpoint-xxx"
model = AutoModel.from_pretrained(model_path, trust_remote_code=True).to(dtype=torch.bfloat16)
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
model.load_adapter(peft_path)
model.eval().cuda()
``
Then, inference
``python
import io
import json
import base64
from PIL import Image
def img2base64(file_name):
with open(file_name, 'rb') as f:
encoded_string = base64.b64encode(f.read())
return encoded_string
im_64 = img2base64('/mnt/workspace/xray/data/images/99_2.png')
question = [{"role": "user", "content": "描述一下"}]
inputs = {"image": im_64, "question": json.dumps(question)}
image = Image.open(io.BytesIO(base64.b64decode(inputs['image']))).convert('RGB')
msgs = json.loads(inputs['question'])
answer, context, _ = model.chat(
image=image,
msgs=msgs,
context=None,
tokenizer=tokenizer,
sampling=True,
temperature=0.7)
print(msgs[-1]["content"]+'\n', answer)
```
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
Use the code below to get started with the model.
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
BibTeX:
[More Information Needed]
APA:
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]