code: https://github.com/tersekmatija/lwcc
Introduction
LWCC是一个轻量级的Python人群计数框架。它包含了四种最先进的模型,都基于卷积神经网络:CSRNet、贝叶斯人群计数、DM-Count和SFANet。该库基于PyTorch。
使用方法
from lwcc import LWCC
import os
import cv2
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"
if __name__ == '__main__':
import matplotlib.pyplot as plt
img = "./data/crowd4.jpg"
model = LWCC.load_model(model_name="Bay", model_weights="SHA")
count, density = LWCC.get_count(img, model=model, return_density=True)
print(f'the number of people:{count}')
image = cv2.imread(img)
plt.subplot(121)
plt.imshow(image)
plt.subplot(122)
plt.imshow(density)
plt.show()