INNER CODE UNIT · Python
image_dir_to_json
idealo/image-quality-assessment · src/evaluater/predict.py:18
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
def predict(model, data_generator):
return model.predict_generator(data_generator, workers=8, use_multiprocessing=True, verbose=1)
def main(base_model_name, weights_file, image_source, predictions_file, img_format='jpg'):
# load samples
if os.path.isfile(image_source):