Recent content by BRN

  1. B

    Tensorflow checkpoints in training model

    Hello everyone, this is part of the code for a cycleGAN model that I have implemented, and it is the part related to training #======================================================================================================================= # cycleGAN architecture...
  2. B

    Python Problem with scikit-learn metrics in K-fold cross validation

    Maybe I explained myself wrong. I wonder why the accuracy calculated with the Scikit-Learn metrics is not comparable with the one displayed during training.
  3. B

    Python Problem with scikit-learn metrics in K-fold cross validation

    Hello everyone, In my implementation of a K-Fold Cross Validation, I find a difference between the accuracy calculated during each training and the average accuracy calculated through the metric functions of Scikit-Learn. This is my code for the K-Fold Cross Validation and for the calculation...
  4. B

    Python Colab doesn't save cycleGAN images correctly

    Hi everyone, I made an implementation of the cycleGAN model but I find a strange problem. If I run the model with a PC supplied to the university it works, while on Colab, it saves me empty PNG files. Consider that I use a standard GPU on Colab. This is my code to save the generated images...
  5. B

    Python UnimplementedError: Cast string to float is not supported

    That's right, this was the problem. Here the correct code def load_and_norm(filename): img = tf.io.read_file(filename) # get only filename string img = tf.image.decode_png(img, channels = 3) # necesary converting to tensor img = tf.cast(img, tf.float32) / 127.5 - 1 # normalization...
  6. B

    Python UnimplementedError: Cast string to float is not supported

    Hello everyone, I have this problem that I can't solve: I have two types of images contained in two different folders. I have to create a dataset with these images and train a cycleGAN model, but for simplicity we assume that I want to print them on monitor and forget the cycleGAN. My code is...
  7. B

    Python How to resize and save a slice from a nii file as a PNG image in Python?

    Oops! I forgot to update this post ...:-p The problem was given by the 'Mathshow ()' function that adds additional spaces around the figure even if the axes are hidden. I solved this way: def img_from_nii(height, width, n_slice, label, in_path, temp_path): filenames =...
  8. B

    Python How to resize and save a slice from a nii file as a PNG image in Python?

    If as Image class you mean that of Pillow, yes there is the save method, but it does not support 32-bit images and I lose quality. By opening the image with any reader, I see the image in the correct size 256x256, but I also have two completely empty side bands. I believe that the save method...
  9. B

    Python How to resize and save a slice from a nii file as a PNG image in Python?

    Hello everyone, I have to extract a slice from a nii files and resize it with dimensions 256x256. Once this is done, I have to save it as a PNG image. This is my code: def img_from_nii(height, width, n_slice, label, in_path, temp_path): filenames = os.listdir(in_path) for i...
  10. B

    Python Converting grayscale images to RGB with Tensorflow

    Oops! what a shame!😅 What a trivial error I made. I apologize. I have to stop writing codes overnight. I promise!😁 Thank you all for your answers!
  11. B

    Python Converting grayscale images to RGB with Tensorflow

    Hello! For my project I need to converting some images from grayscale to RGB using Tesorflow. My code is this: image_grayscale = tf.io.read_file('image_bw.png') image_grayscale = tf.image.decode_png(image_grayscale, channels=1) image_grayscale = tf.convert_to_tensor(image_grayscale[:,:,:3])...
  12. B

    Python Generating Images with CNN: Why is the Size Not Increasing in Each Layer?

    Hello and thanks! You're right, CNN means Convolutional Neural Network. Next time I will write the acronyms explicitly :smile:
  13. B

    Python Generating Images with CNN: Why is the Size Not Increasing in Each Layer?

    Ok, I have the solution. The size of the outputs of a CNN "conv" is given by the equation $$o=\left ( \frac{i - k + 2p}{s} \right )+1$$ but, as in my case, for a transpose convolution "deconv" the size of the outputs is $$o=s\left (i -1 \right )+ k - 2p$$ Then, with stride ##s=2##, the...
  14. B

    Python Generating Images with CNN: Why is the Size Not Increasing in Each Layer?

    Hello everybody, I have this problem: starting from a vector of 100 random values, I have to generate an image of size 128x128x3 using a model consisting of a fully completely layer and 5 layer deconv. This is my model def generator_model(noise_dim): n_layers = 5 k_w, k_h = [8, 8]...
  15. B

    Python Loading .nii images while saving memory

    I hope it can be done, but at the moment I don't know how. Should the iterator be implemented directly in the loss function of the GAN discriminator? def discriminator_model(strides, kernel_size, input_img, weight_initializer, downsample_layers): rate = 0.2 filters =...
Back
Top