davideverona / deep-crowd-counting_crowdnet Goto Github PK
View Code? Open in Web Editor NEWAn independent implementation of "CrowdNet: A Deep Convolutional Network for Dense Crowd Counting"
An independent implementation of "CrowdNet: A Deep Convolutional Network for Dense Crowd Counting"
Here is my test for density map creation, I draw 10 random points and than create density map, however sum over map is not 10, but 6.95563, for 100 points it's 91.6066 and it depens on point positions, how can we approximate it more precise?
import numpy as np
import scipy
import scipy.spatial
import scipy.ndimage
import cv2
from random import randint
def gaussian_filter_density(mask):
density = np.zeros(mask.shape, dtype=np.float32)
gt_count = np.count_nonzero(mask)
if gt_count == 0:
return density
pts = np.array(zip(np.nonzero(mask)[1], np.nonzero(mask)[0]))
leafsize = 2048
# build kdtree
tree = scipy.spatial.KDTree(pts.copy(), leafsize=leafsize)
# query kdtree
distances, locations = tree.query(pts, k=2, eps=10.)
for i, pt in enumerate(pts):
pt2d = np.zeros(mask.shape, dtype=np.float32)
pt2d[pt[1],pt[0]] = 1.
if gt_count > 1:
sigma = distances[i][1]
else:
sigma = np.average(np.array(mask.shape))/2./2. #case: 1 point
density += scipy.ndimage.filters.gaussian_filter(pt2d, sigma, mode='constant')
print "np.sum(density): ", np.sum(density)
return density
def test_density():
h= 100
w= 120
mask= np.zeros((h,w))
for i in range(0,10):
y= randint(0,h-1)
x= randint(0,w-1)
mask[y,x]= 1
density= gaussian_filter_density(mask)
cv2.imwrite('mask.png', 255*mask)
cv2.imwrite('density.png', 255*density)
test_density()
HI~
When I calculated the number given by the density map, I found there was a difference between the gt density map before and after downsampling(or resize). So if it is correct to train the model with the downsampled gt density map? Which gt number should be used when evaluating the method? The original number given by the dataset or the number calculated by the downsampled gt density map?
How did you deal with the problem? Thank you.
Hi, I ran the code through and the best iteration was the model saved at 1000 (dcc_crowdnet_train_iter_1000.caffemodel)...
Ground truth Avg: 1642.42 MAE: 812.687
I see David achieved similar error in the pynb on the repo, although a little lower (~700), which is probably due to different test data selected in the 20% test. The paper reported error of ~ 420 over 5 folds. Any idea what the gap may be ? Assuming there is a gap...
Hi @davideverona ,
Thanks for sharing your method.
But i don't know how to make the file of "train.txt", could you please tell me?
It is the best for me if you can provide the "train.txt" and train-datasets.
My email address is [email protected].
Thank you very much!
samylee
Hi @davideverona ,
Could you help me? Please^_^
I realized that the last layer of the output is 28x28, the value of the feature points are less than 1, and even negative numbers. So how do I get the final density map of the image via image mosaic?
It is the best for me if you can provide the code (python or c++). My email address is [email protected].
By the way, The caffemodel that I trained still has some problems, so could you please provide the caffemodel for me? Thanks! And the caffemodel that you trained could be applied to low density populations?
I'm looking forward to your reply. Thank you very much!
Samylee
Can you please share me your ideas to use this code for crowd counting in CCTV cameras?
Thanks
Guru
Hi Davide Verona,
What is the license of this source code?
for out in net.blobs[out_layer].data:
y = out[0] #single channel
Y_deploy.append(y)
the Y_deploy need to be allocated in new memory, or it will be always the last predict result .
Y_deploy.append(y.copy()) is right.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.