人脸照片分类

警告 win7不支持,但也能用。
4827 张时能跑完,还挺快,只需要4分钟!
但210080 张时,就很快报错了!
查了一下是有个mov视频被加了jpg后缀;后来有一个png报错;加了两重try才基本跑下来了
如果except不需要错误名就好了。
另外,即使异常退出,最好也能保存已经得到的部分结果。。。。

for img in tqdm(all_img):
    try:
        try:
            #print(img)
            _img = Im.open(img)
            imga = np.array(_img)
            bboxes, confs, lms = nn_fd.run(imga)
        except UnidentifiedImageError:
            continue
        except OSError:
            continue
        #else:
    except NameError:
        continue

z:\phpto-main>d:python process.py cluster e:\dc\ –out=r:\res.txt
D:\tool\Python\Python37\lib\site-packages\onnxruntime\capi\onnxruntime_validatio
n.py:27: UserWarning: Unsupported Windows version (7). ONNX Runtime supports Win
dows 10 and above, only.
my_distro_ver)
862it [00:00, 1602.14it/s]
100%|██████████████████████████████████████| 4827/4827 [04:00<00:00, 20.05it/s]

z:\phpto-main>d:python process.py cluster e:\dc\ –out=r:\res.txt
D:\tool\Python\Python37\lib\site-packages\onnxruntime\capi\onnxruntime_validatio
n.py:27: UserWarning: Unsupported Windows version (7). ONNX Runtime supports Win
dows 10 and above, only.
my_distro_ver)
862it [00:01, 680.31it/s]
0%| | 2/210080 [00:00<12:34:34, 4.64it/s]
Traceback (most recent call last):
File “process.py”, line 199, in
fire.Fire(CLI())
File “D:\tool\Python\Python37\lib\site-packages\fire\core.py”, line 141, in Fi
re
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File “D:\tool\Python\Python37\lib\site-packages\fire\core.py”, line 471, in _F
ire
target=component.name)
File “D:\tool\Python\Python37\lib\site-packages\fire\core.py”, line 681, in _C
allAndUpdateTrace
component = fn(*varargs, **kwargs)
File “process.py”, line 192, in cluster
_cluster(source, fd, fr, out, do_copy, dst)
File “process.py”, line 90, in _cluster
bboxes, confs, lms = nn_fd.run(imga)
File “z:\phpto-main\nn\fd_with_lm.py”, line 135, in run
img = self.preprocess(img, rgb_reverse)
File “z:\phpto-main\nn\fd_with_lm.py”, line 151, in preprocess
img -= (104, 117, 123)
ValueError: operands could not be broadcast together with shapes (640,640,4) (3,
) (640,640,4)

这些我都记下来,迭代版本加上,哈哈 :grin:

建议改为写入exif?可选批量将ID改为人名?
路人的建议哈~