INNER CODE UNIT · Python
image_file_to_json
idealo/image-quality-assessment · src/evaluater/predict.py:11
def image_file_to_json(img_path):
img_dir = os.path.dirname(img_path)
img_id = os.path.basename(img_path).split('.')[0]
return img_dir, [{'image_id': img_id}]
def image_dir_to_json(img_dir, img_type='jpg'):
img_paths = glob.glob(os.path.join(img_dir, '*.'+img_type))
samples = []
for img_path in img_paths:
img_id = os.path.basename(img_path).split('.')[0]
samples.append({'image_id': img_id})
return samples