ustlsh / TransPro

MIT License
13 stars 3 forks source link

Questions Regarding train3d.py: Multiprocessing on Windows and Input Data Format #4

Open brianchu-1248 opened 3 days ago

brianchu-1248 commented 3 days ago

Hi author,

Thank you for sharing the TransPro codebase! It’s been a great resource for my research, and I’m currently working on running the train3d.py script. However, I’ve encountered a couple of issues and would greatly appreciate your advice:

  1. Operating System Compatibility I’m running the code in a Windows environment and ran into a multiprocessing issue. The error suggests using the if name == 'main': syntax to fix it. Could you kindly let me know if the code was developed and tested on Windows, or if it’s optimized for Linux systems? If you’ve used Windows, are there any specific steps or adjustments I should follow to resolve this issue?

  2. Input Data Format I noticed that the input data paths seem to reference .bmp files. However, when running the script, I encountered the following error: 'raise pickle.UnpicklingError: Could not load file containing pickled data' Could you clarify if the input data should indeed be in .bmp format, or if there is a preprocessing step required (e.g., converting data to .npy)?

Lastly, if it’s not too much trouble, may I ask if you’d be open to sharing your preferred method of contact (e.g., email or other platforms) for further clarification if needed?

Thank you very much for your time and help. I truly appreciate the effort you’ve put into this project and look forward to your guidance!

Best regards, brianchu-1248

ustlsh commented 2 days ago

Thank you for your attention. For your questions:

  1. I implemented this project using Linux system, so problems may exist when switching to Windows.
  2. You need to convert original .bmp file to .npy file using the following script:
    
    from PIL import Image
    import numpy as np
    import glob
    import os

img_dir = "xx/xx/octa-500/OCTA_6M_OCTA_part1" # change by yourself save_dir = "./octa-500/OCT2OCTA6M_3D/train/B/" # change by yourself

if not os.path.exists(save_dir): os.makedirs(save_dir)

file_list = [] for subdir, dirs, files in os.walk(img_dir): for f in files: if "bmp" in f: file_list.append(os.path.join(subdir, f)) file_list.sort() print(file_list[0]) print(len(file_list))

6M

img_path = ./OCTA/octa-500/OCTA_6M_OCTA_part3/10201/1.bmp

for k in range(100):

pid = file_list[k*304].split('/')[-2] # 3M

pid = file_list[k*400].split('/')[-2] # 6M
print(pid)
# img_3d = np.zeros((304,256,304)) # 3M
img_3d = np.zeros((400,256,400))  # 6M
# for i in range (k*304, k*304+304): # 3M
for i in range (k*400, k*400+400):
    img_path = file_list[i]
    #pid_ = img_path.split('/')[-1].split('_')[0]
    pid_ = img_path.split('/')[-2]
    assert(pid == pid_)
    #idx = int(img_path.split('/')[-1].split('_')[1][:-4])
    idx = int(img_path.split('/')[-1].split('.')[0])
    img = Image.open(img_path)
    img = img.resize((304,256)) # 3M
    img = img.resize((400,256)) # 6M
    arr_img = np.array(img) # 256,400, 6M; 256, 304, 3M
    #img_3d[idx-1,:,:]=arr_img[:,:,0]
    img_3d[idx-1,:,:]=arr_img
    img_3d = (img_3d-img_3d.min())/(img_3d.max()-img_3d.min())
    np.save(save_dir+pid+'.npy', img_3d)