(netG,
                           num_samples,
                           sess,
                           device,
                           seed,
                           batch_size,
                           print_every=20,
                           verbose=True)
return m_fake, s_fake
Directly produces the images and convert them into numpy format without
    saving the images on disk.

    Args:
        netG (Module): Torch Module object representing the generator model.
        num_samples (int): The number of fake images for computing statistics.
        sess (Session): TensorFlow session to use.
        device (str): Device identifier to use for computation.
        seed (int): The random seed to use.
        batch_size (int): The number of samples per batch for inference.
        print_every (int): Interval for printing log.
        verbose (bool): If True, prints progress.

    Returns:
        ndarray: Mean features stored as np array.
        ndarray: Covariance of features stored as np array.
Directly produces the images and convert them into numpy format without
    saving the images on disk.
Directly produces the images and convert them into numpy format without saving the images on disk .
def compute_gen_dist_stats(netG,
                           num_samples,
                           sess,
                           device,
                           seed,
                           batch_size,
                           print_every=20,
                           verbose=True):
    """
    Directly produces the images and convert them into numpy format without
    saving the images on disk.

    Args:
        netG (Module): Torch Module object representing the generator model.
        num_samples (int): The number of fake images for computing statistics.
        sess (Session): TensorFlow session to use.
        device (str): Device identifier to use for computation.
        seed (int): The random seed to use.
        batch_size (int): The number of samples per batch for inference.
        print_every (int): Interval for printing log.
        verbose (bool): If True, prints progress.

    Returns:
        ndarray: Mean features stored as np array.
        ndarray: Covariance of features stored as np array.
    """
    # Set model to evaluation mode
    netG.eval() # NOTE: in MegEngine this may has no effect

    # Inference variables
    batch_size = min(num_samples, batch_size)

    # Collect all samples()
    images = []
    start_time = time.time()
    for idx in range(num_samples // batch_size):
        # Collect fake image
        fake_images = netG.generate_images(num_images=batch_size).numpy()
        images.append(fake_images)

        # Print some statistics
        if (idx + 1) % print_every == 0:
            end_time = time.time()
            print(
                "INFO: Generated image {}/{} [Random Seed {}] ({:.4f} sec/idx)"
                .format(
                    (idx + 1) * batch_size, num_samples, seed,
                    (end_time - start_time) / (print_every * batch_size)))
            start_time = end_time

    # Produce images in the required (N, H, W, 3) format for FID computation
    images = np.concatenate(images, 0)  # Gives (N, 3, H, W) BGR
    images = _normalize_images(images)  # Gives (N, H, W, 3) RGB

    # Compute the FID
    print("INFO: Computing statistics for fake images...")
    m_fake, s_fake = fid_utils.calculate_activation_statistics(
        images=images, sess=sess, batch_size=batch_size, verbose=verbose)

    return m_fake, s_fake
def compute_gen_dist_stats ( netG , num_samples , sess , device , seed , batch_size , print_every = 20 , verbose = True ) : # Set model to evaluation mode netG . eval ( ) # NOTE: in MegEngine this may has no effect # Inference variables batch_size = min ( num_samples , batch_size ) # Collect all samples() images = [ ] start_time = time . time ( ) for idx in range ( num_samples // batch_size ) : # Collect fake image fake_images = netG . generate_images ( num_images = batch_size ) . numpy ( ) images . append ( fake_images ) # Print some statistics if ( idx + 1 ) % print_every == 0 : end_time = time . time ( ) print ( "INFO: Generated image {}/{} [Random Seed {}] ({:.4f} sec/idx)" . format ( ( idx + 1 ) * batch_size , num_samples , seed , ( end_time - start_time ) / ( print_every * batch_size ) ) ) start_time = end_time # Produce images in the required (N, H, W, 3) format for FID computation images = np . concatenate ( images , 0 ) # Gives (N, 3, H, W) BGR images = _normalize_images ( images ) # Gives (N, H, W, 3) RGB # Compute the FID print ( "INFO: Computing statistics for fake images..." ) m_fake , s_fake = fid_utils . calculate_activation_statistics ( images = images , sess = sess , batch_size = batch_size , verbose = verbose ) return m_fake , s_fake