shikiw/SI-Adv

wonder how to visualize the sensitive maps.

kkkcx opened this issue · 6 comments

kkkcx commented

Thanks for your great work.
I wonder how to visualize the sensitive maps as in your paper.
Thank you in advance!

Thanks for your appreciation!
In fact, the sensitive scores can be obtained here:

rankings = torch.sqrt(grad[:,:,0] ** 2 + grad[:,:,1] ** 2) # \sqrt{g_{x'}^2+g_{y'}^2}, [1, N]

then you can concatenate the point coordinates with these scores, i.e., (x, y, z, score), and apply this function:

SI-Adv/main.py

Lines 75 to 86 in 63f082d

def save_tensor_as_txt(points, filename):
"""Save the torch tensor into a txt file.
"""
points = points.squeeze(0).detach().cpu().numpy()
with open(filename, "a") as file_object:
for i in range(points.shape[0]):
# msg = str(points[i][0]) + ' ' + str(points[i][1]) + ' ' + str(points[i][2])
msg = str(points[i][0]) + ' ' + str(points[i][1]) + ' ' + str(points[i][2]) + \
' ' + str(points[i][3].item()) +' ' + str(points[i][3].item()) + ' '+ str(1-points[i][3].item())
file_object.write(msg+'\n')
file_object.close()
print('Have saved the tensor into {}'.format(filename))

to save the concatenated result into .txt format (other point cloud formats are also fine).
Each line of the .txt file corresponds to the (x, y, z, score) of each point.
With this file, the sensitive map can be visualized by MeshLab or blensor as you like :)

kkkcx commented

Thank you for your detailed reply!

Hello,

pretty much a noob here and I am still wondering how to render. I am unable to completely understand how to

then you can concatenate the point coordinates with these scores, i.e., (x, y, z, score), and apply this function:

do this part here, I am assuming that the part you mentioned is already available at the line number 524 as:
sorted_point_list = sorted(point_list, key=lambda c: c[2], reverse=True)

I am using the following method to execute with the target method as ifgm_ours:
python main.py --transfer_attack_method ifgm_ours
Could you guide me here? Appreciate your work and the help. Thanks.

Hello,

pretty much a noob here and I am still wondering how to render. I am unable to completely understand how to

then you can concatenate the point coordinates with these scores, i.e., (x, y, z, score), and apply this function:

do this part here, I am assuming that the part you mentioned is already available at the line number 524 as: sorted_point_list = sorted(point_list, key=lambda c: c[2], reverse=True)

I am using the following method to execute with the target method as ifgm_ours: python main.py --transfer_attack_method ifgm_ours Could you guide me here? Appreciate your work and the help. Thanks.

Thanks for your appreciation!

The part at Line 524 is used for ranking the point in a descending order according to their sensitive scores, which is not necessary for visualization since visualizing a point cloud is usually independent of the point order in the point cloud data.
Therefore, to realize this part:

then you can concatenate the point coordinates with these scores, i.e., (x, y, z, score), and apply this function:

First, we have the benign point cloud (x, y, z) with the shape as and the sensitive scores corresponding to these points with the shape as .
Then, we can concatenate them and acquire the tensor (x, y, z, score) with the shape as .
Finally, we can apply this function:

SI-Adv/main.py

Lines 75 to 86 in 63f082d

def save_tensor_as_txt(points, filename):
"""Save the torch tensor into a txt file.
"""
points = points.squeeze(0).detach().cpu().numpy()
with open(filename, "a") as file_object:
for i in range(points.shape[0]):
# msg = str(points[i][0]) + ' ' + str(points[i][1]) + ' ' + str(points[i][2])
msg = str(points[i][0]) + ' ' + str(points[i][1]) + ' ' + str(points[i][2]) + \
' ' + str(points[i][3].item()) +' ' + str(points[i][3].item()) + ' '+ str(1-points[i][3].item())
file_object.write(msg+'\n')
file_object.close()
print('Have saved the tensor into {}'.format(filename))

to save the tensor (x, y, z, score) into the .txt format, where each line means (x, y, z, R, G, B). Different RGB colors indicate different sensitive scores (Also, you can change to use other color styles).
We can import the .txt file in MeshLab and the point cloud sensitivity map will be visualized :)

Great, thanks for sharing and I'll work on that. However, I had one other question unrelated to this topic, is there any way I can speed up the dataset loading process, it looks like as of now it takes upwards of 15 mins to load the entire dataset. Let me know if I am missing something or if anything can be done about it.

Thanks.

Edit: The way I am loading dataset is mounting the code directory that has the dataset with type bind to a docker container.

Great, thanks for sharing and I'll work on that. However, I had one other question unrelated to this topic, is there any way I can speed up the dataset loading process, it looks like as of now it takes upwards of 15 mins to load the entire dataset. Let me know if I am missing something or if anything can be done about it.

Thanks.

Edit: The way I am loading dataset is mounting the code directory that has the dataset with type bind to a docker container.

When running the code for the first time, it will take a few mins to automatically compile the cuda extension for CurveNet. So I guess the mentioned 15 mins are taken for compiling this cuda extension rather than loading the dataset. Will it be quite faster when you run the code for the second time? If not, I guess I also have no idea about how to deal with it.