ExplainableFaceImageQuality
ExplainableFaceImageQuality copied to clipboard
Error while running XFIQ
Hey, folks! I encountered the following problem while running the XFIQ.py
File "XFIQ.py", line 109, in <module>
run(image_path, model_path, grad_path, T)
File "XFIQ.py", line 82, in run
np.save(save_path, save)
File "<__array_function__ internals>", line 200, in save
File "/home/shynggys/openvino_2021/lib/python3.8/site-packages/numpy/lib/npyio.py", line 521, in save
arr = np.asanyarray(arr)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (2, 3) + inhomogeneous part
I got installed:
Python 3.8
opencv-python=4.6.0.66
Tensorflow=2.7.3
numpy=1.24.0
sklearn=1.2.0
matplotlib=3.6.2
tqdm=4.63.1
Dear abdu-Khmad, only with the error message it is difficult to understand the error. Can you give us more information? Best, Marco
This is because numpy dosen't support save (string, ndarray, score) direct into numpy. You need modify the XFIQ.py and explain_quality.py
- XFIQ.py
...
dtype = np.dtype([('path', 'U50'), ('gradients', np.ndarray), ('score', float)])
def run(image_path, model_path, save_path, T):
...
# calculating quality and gradients for each image
for i in tqdm(images):
...
# add to save
tmp = (i, grads, score)
save.append(tmp)
# make tri-tuple into numpy array
data_array = np.array(save, dtype=dtype)
# save
np.save(save_path, data_array)
if __name__ == "__main__":
...
# Explain Face Image Quality at Pixel-Level
run(image_path, model_path, grad_path, T)
loaded_gradients = np.load(grad_path, allow_pickle=True)
loaded_gradients = loaded_gradients.astype(dtype)
plot_comparison(loaded_gradients, plot_path, a, b, True)
- explain_quality.py
# in plot_comparison, update get names, grads and score
names, grads, score = grad_save['path'], grad_save['gradients'], grad_save['score']
I have tested this model with faces captured under surveillance system, most of faces are getting low score. Maybe it is not proper to surveillance system. @pterhoer do you have any suggest?
I guess due to the scenario, the general image and face image quality are lower. To still visualize the differences you can adapt the gamma parameter (eq 6). Best Philipp