Modify eval_mm for MiniCPM-V 2.6

This commit is contained in:
Haoyu Li
2024-08-30 18:18:22 +00:00
parent ab1141ee45
commit 59224808a1
69 changed files with 8231 additions and 1818 deletions

View File

@@ -18,8 +18,8 @@ from multiprocessing import Pool, current_process
from tqdm import tqdm
import datetime
import matplotlib.pyplot as plt
import seaborn as sns
from tabulate import tabulate_formats, tabulate
from tabulate import tabulate
from json import JSONDecoder
from huggingface_hub import scan_cache_dir
from sty import fg, bg, ef, rs
@@ -71,7 +71,7 @@ def bincount(lst):
bins[item] += 1
return bins
def get_cache_path(repo_id):
def get_cache_path(repo_id, branch=None):
hf_cache_info = scan_cache_dir()
repos = list(hf_cache_info.repos)
repo = None
@@ -82,6 +82,8 @@ def get_cache_path(repo_id):
if repo is None:
return None
revs = list(repo.revisions)
if branch is not None:
revs = [r for r in revs if r.refs == frozenset({branch})]
rev2keep, last_modified = None, 0
for rev in revs:
if rev.last_modified > last_modified:
@@ -189,3 +191,26 @@ def version_cmp(v1, v2, op='eq'):
import operator
op_func = getattr(operator, op)
return op_func(version.parse(v1), version.parse(v2))
def toliststr(s):
if isinstance(s, str) and (s[0] == '[') and (s[-1] == ']'):
return [str(x) for x in eval(s)]
elif isinstance(s, str):
return [s]
elif isinstance(s, list):
return [str(x) for x in s]
raise NotImplementedError
def extract_json_objects(text, decoder=JSONDecoder()):
pos = 0
while True:
match = text.find('{', pos)
if match == -1: break
try:
result, index = decoder.raw_decode(text[match:])
yield result
pos = match + index
except ValueError:
pos = match + 1