(self, input)
| 167 | self.model.eval().cuda() |
| 168 | |
| 169 | def chat(self, input): |
| 170 | try: |
| 171 | image = Image.open(io.BytesIO(base64.b64decode(input['image']))).convert('RGB') |
| 172 | except Exception as e: |
| 173 | return "Image decode error" |
| 174 | |
| 175 | msgs = json.loads(input['question']) |
| 176 | |
| 177 | answer = self.model.chat( |
| 178 | image=image, |
| 179 | msgs=msgs, |
| 180 | tokenizer=self.tokenizer, |
| 181 | sampling=True, |
| 182 | temperature=0.7 |
| 183 | ) |
| 184 | return answer |
| 185 | |
| 186 | class MiniCPMV2_6: |
| 187 | def __init__(self, model_path, multi_gpus=False) -> None: |