mirror of
https://github.com/Vision-CAIR/MiniGPT-4.git
synced 2025-04-07 19:40:45 +00:00
Evaluation (Version 1) (including Quantitative & Qualitative) WIP: Reconstruct the eval part & config part --------- Co-authored-by: unknown <913556700@qq.com> Co-authored-by: bingyikang <bingyikang@bytedance.com>
16 lines
491 B
Python
16 lines
491 B
Python
import torch
|
|
from PIL import Image
|
|
|
|
|
|
def load_image(image, image_processor):
|
|
if isinstance(image, str): # is a image path
|
|
raw_image = Image.open(image).convert('RGB')
|
|
image = image_processor(raw_image).unsqueeze(0)
|
|
elif isinstance(image, Image.Image):
|
|
raw_image = image
|
|
image = image_processor(raw_image).unsqueeze(0)
|
|
elif isinstance(image, torch.Tensor):
|
|
if len(image.shape) == 3:
|
|
image = image.unsqueeze(0)
|
|
return image
|