abduallahmohamed / Social-STGCNN

Code for "Social-STGCNN: A Social Spatio-Temporal Graph Convolutional Neural Network for Human Trajectory Prediction" CVPR 2020
MIT License
483 stars 141 forks source link

I am very curious about the element in your proposed adjacency matrix #67

Open WangHonghui123 opened 1 year ago

WangHonghui123 commented 1 year ago

When I see your code, why do you use the relative position to calculate the norm between two nodes in a graph under a frame, shown as follows (The related code has been bold):

def seq_tograph(seq,seq_rel,norm_lapmatr = True): seq = seq_.squeeze() seq_rel = seq_rel.squeeze() seqlen = seq.shape[2] maxnodes = seq.shape[0] V = np.zeros((seq_len,max_nodes,2)) A = np.zeros((seq_len,max_nodes,max_nodes)) for s in range(seqlen): step = seq_[:,:,s] step_rel = seqrel[:,:,s] for h in range(len(step)): V[s,h,:] = steprel[h] A[s,h,h] = 1 for k in range(h+1,len(step)): l2_norm = anorm(step_rel[h],step_rel[k]) A[s,h,k] = l2_norm A[s,k,h] = l2_norm if norm_lap_matr:
G = nx.from_numpy_matrix(A[s,:,:]) A[s,:,:] = nx.normalized_laplacian_matrix(G).toarray()
return torch.from_numpy(V).type(torch.float),\ torch.from_numpy(A).type(torch.float)

abduallahmohamed commented 1 year ago

Hi Wang, Thanks for reaching out. Relative position is a form of normalization for the data. Other methods are relative change w.r.t initial point, middle or last observed point. Also, this is a form of using the relative speed instead of position, it's kind of a better signal. Hope this helps.

WangHonghui123 commented 1 year ago

Hi Wang, Thanks for reaching out. Relative position is a form of normalization for the data. Other methods are relative change w.r.t initial point, middle or last observed point. Also, this is a form of using the relative speed instead of position, it's kind of a better signal. Hope this helps.

Thank you for your answer.

From your code regarding data processing, step_rel[h] is just like the vector pointing from the previous absolute position to the current absolute position for a certain pedestrian. If this is form of using relative speed, why don't you use the finite difference to calculate since the frame rate is 0.4 for ETH/UCY dataset.

I am looking forward to getting your explanation.

abduallahmohamed commented 1 year ago

There is no issue in using FD (computation cost?) The step_rel amplifies noise too. Probably, changing the "normalization" method can enhance the results, by how much % vs current results and accounting for extra computational cost is something to look at. I encourage you to look into our latest work Social-Implicit which also uses other datasets.