Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create simulated training datasets? #2

Open
ManuBN786 opened this issue Aug 13, 2024 · 2 comments
Open

How to create simulated training datasets? #2

ManuBN786 opened this issue Aug 13, 2024 · 2 comments

Comments

@ManuBN786
Copy link

I have downloaded BioSR train & test .npz from the links you provided.

Can you please provide examples to generate training datasets using :

generate_training_set(n_samples, n_batches, sample_shape, kernel_shape, paths=None)

and

generate_synthetic_sample()

how to define n_batches, sample_shape, shape_img & kernel_shapes for BioSR please?

@nanoxas
Copy link
Collaborator

nanoxas commented Aug 13, 2024

Hi, you need to add the option to generate a synthetic sample from the BioSR dataset. Using the generate_syntetic_sample function, you need to change the part of the code that says to load image net data. There you need to change the file read from imagenet to biosr (load the npz and load one image of the array). This function will generate the psf for the widefield image and the confocal image.

ix = np.random.randint(0, len(im_net_paths)) path = str(im_net_paths[ix]) img = cv2.imread(path) img = cv2.resize(img, (shape_img[1], shape_img[0]), interpolation=cv2.INTER_AREA) img_gray = np.expand_dims(cv2.cvtColor(img, cv2.COLOR_BGR2GRAY), axis=0) / 255.

this is the code you need to change. As for the parameters, n_batches is how many folders of n_samples you want to have, shape_img is the size of your image, and kernel_shape is the size of the kernel, for the case of biosr is 256x256 for both, although the kernel can be smaller. Store all data as you need it for training, as the training script will also run the forward convolution model to train the model. Once you have the generated PSFs, run the training script. As you can see from the trainer the code will read the biosr npz obtain the 'y' tensor (your GT) apply the forward model to obtain the inputs and run the physics-informed optimization.

@ManuBN786
Copy link
Author

ManuBN786 commented Sep 2, 2024

I tried to generate a psf from the code.

I used:

generate_training_set(10,1,(256,256,1),(256,256),None)

& tried to visualize PSF generated from it.

But it says that some value is too large.

How to fix this ?

How to actually give values to generate a psf?

I get the same " too large try a small one" even if I mention a the path of the biosr test.npz

generate_training_set(10680,100,(256,256),(256,256),paths="/data/BioSR/npz_folder/")

Screenshot from 2024-09-02 17-00-30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants