🔧 AI Nachrichten Major AI platforms go down in unprecedented simultaneous outage(03.09.2026 um 17:34 Uhr)
🔧 AI Nachrichten ChatGPT, Claude, and Grok Down? Users Report Widespread Outages(03.09.2026 um 19:14 Uhr)
🔧 AI Nachrichten OpenAI Launches GPT-6 Astra, Says We May Have Entered the AGI Era(03.09.2026 um 22:08 Uhr)
🔧 AI Nachrichten Claude Comes to CarPlay as Fifth Major AI Chatbot App(05.09.2026 um 05:31 Uhr)
🔧 AI Nachrichten OpenAI’s GPT-6 Astra Is AGI, Says NVIDIA CEO Jensen Huang(07.09.2026 um 06:31 Uhr)
🔧 AI Nachrichten Blame AI companies for Mac mini and Mac Studio shortage(31.08.2026 um 10:32 Uhr)
🔧 AI Nachrichten Major AI platforms go down in unprecedented simultaneous outage(03.09.2026 um 17:34 Uhr)
🔧 AI Nachrichten ChatGPT, Claude, and Grok Down? Users Report Widespread Outages(03.09.2026 um 19:14 Uhr)
🔧 AI Nachrichten OpenAI Launches GPT-6 Astra, Says We May Have Entered the AGI Era(03.09.2026 um 22:08 Uhr)
🔧 AI Nachrichten Claude Comes to CarPlay as Fifth Major AI Chatbot App(05.09.2026 um 05:31 Uhr)
🔧 AI Nachrichten OpenAI’s GPT-6 Astra Is AGI, Says NVIDIA CEO Jensen Huang(07.09.2026 um 06:31 Uhr)
🔧 AI Nachrichten Blame AI companies for Mac mini and Mac Studio shortage(31.08.2026 um 10:32 Uhr)

🎥 Künstliche Intelligenz Videos 🕛 kürzlich 16 Min Lesezeit
0

Our Summer of Code Project on TF-GAN

↗ Quelle (blog.tensorflow.org)
🗣️ Stimme:
📑 Inhaltsübersicht
📺
blog.tensorflow.org

Posted by , is a program that brings student developers into open-source projects each summer. This article describes enhancements made to the library by adding new tutorials, and adding new functionality to the library itself.

This article provides an overview of TF-GAN and our accomplishments from last summer. We will share our experience from the perspective of both the student and the mentors, and walk through one of the new tutorials Nived created, an , the team has viewed by over 150K people in 2020, and an . Papers using TF-GAN have thousands of citations (e.g. , , , , . Each of these different parts can be used to simplify the training or evaluation process of GANs.

Project Scope

The . Through this project new loss functions were also added to the library that can improve the training process of GANs. Next, we will walk through the ESRGAN code and demonstrate how to use TF-GAN to help with training and evaluation.

If you are new to GANs, a good start is to read this on tensorflow.org and the self-study ) introduced the concept of single-image super resolution and used residual blocks and perception loss to achieve that. The ESRGAN ( and the other . After you create a storage bucket, let’s authenticate from Colab so that you can grant Google Cloud SDK access to the bucket:

PYTHON
bucket = 'enter-your-bucket-name-here'
tpu_address = 'grpc://{}'.format(os.environ['COLAB_TPU_ADDR'])

from google.colab import auth
auth.authenticate_user()

tf.config.experimental_connect_to_host(tpu_address)
tensorflow_gcs_config.configure_gcs_from_colab_auth()

You will be prompted to follow a link in your browser to authenticate the connection to the bucket. Click on the link will take you to a new browser tab. Follow the instructions there to get the verification code then go back to the Colab notebook to enter the code. Now you should be able to access the bucket for the rest of the notebook.

Training parameters

Now that we have enabled TPU for Colab and set up GCS cloud bucket to store training data and model weights, we first define some parameters that will be used from data loading to model training, such as the batch size, HR image resolution and the scale by which to downscale the image into LR etc.

PYTHON
Params = {
'batch_size' : 32, # Number of image samples used in each training step
'hr_dimension' : 256, # Dimension of a High Resolution (HR) Image
'scale' : 4, # Factor by which Low Resolution (LR) Images to be downscaled.
'data_name': 'div2k/bicubic_x4', # Dataset name - loaded using tfds.
'trunk_size' : 11, # Number of Residual blocks used in Generator
...
}

Data

We are using the ) - calculated for both G and D.

  • Perceptual loss - calculated using the pre-trained VGG-19 network.
  • Let’s dive deeper into the adversarial loss here since this is the most complex one and it’s a function added to the TF-GAN library as part of the project.

    In GANs the discriminator network classifies the input data as real or fake. The generator is trained to generate fake data and fool the discriminator into mistakenly classifying it as real. As the generator increases the probability of fake data being real, the probability of real data being real should also decrease. This was a missing property of standard GANs as pointed out in this for the implementation of this loss function.

    PYTHON
    def ragan_generator_loss(d_real, d_fake):
    real_logits = d_real - tf.reduce_mean(d_fake)
    fake_logits = d_fake - tf.reduce_mean(d_real)
    real_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(
    labels=tf.zeros_like(real_logits), logits=real_logits))
    fake_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(
    labels=tf.ones_like(fake_logits), logits=fake_logits))

    return real_loss + fake_loss

    def ragan_discriminator_loss(d_real, d_fake):
    def get_logits(x, y):
    return x - tf.reduce_mean(y)
    real_logits = get_logits(d_real, d_fake)
    fake_logits = get_logits(d_fake, d_real)

    real_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(
    labels=tf.ones_like(real_logits), logits=real_logits))
    fake_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(
    labels=tf.zeros_like(fake_logits), logits=fake_logits))

    return real_loss + fake_loss

    Training

    The ESRGAN model is trained in two phases:

    • Phase 1: train the generator network individually and is aimed at improving the PSNR values of generated images by reducing the L1 loss.
    • Phase 2: continue training of the same generator model along with the discriminator network. In the second phase, the generator reduces the L1 Loss, Relativistic average GAN (RaGAN) loss which indicates how realistic the generated image looks and the improved Perceptual loss proposed in the paper.

    If starting from scratch, phase-1 training can be completed within an hour on a free colab TPU, whereas phase-2 can take around 2-3 hours to get good results. As a result saving the weights/checkpoints are important steps during training.

    Phase 1 training

    Here are the steps of phase 1 training:

    • Define the generator and its optimizer
    • Take LR, HR image pairs from the training dataset
    • Input the LR image to the generator network
    • Calculate the L1 loss using the generated image and HR image
    • Calculate gradient value and apply it to the optimizer
    • Update the learning rate of optimizer after every decay steps for better performance

    Phase 2 training

    In this phase of training:

    • Load the generator network trained in phase 1
    • Define checkpoints that can be useful during training
    • Use VGG-19 pretrained network for calculating perceptual loss

    Then we define the training step as follows:

    • Input the LR image to the generator network
    • Calculate L1 loss, perceptual loss and adversarial loss for both the generator and the discriminator.
    • Update the optimizers for both networks using the obtained gradient values
    • Update the learning rate of optimizers after every decay steps for better performance
    • TF-GAN's image grid function is used to display the generated images in the validation steps

    Please refer to the

    Here are some more results at the end of the training which look pretty good.

    Evaluation

    Now that training has completed, we will evaluate the ESRGAN model with 3 metrics: Fréchet Inception Distance (FID), Inception Scores and Peak signal-to-noise ratio (PSNR).

    FID and Inception Scores are two common metrics used to evaluate the performance of a GAN model. Peak Signal-to- Noise Ratio (PSNR) is used to quantify the similarity between two images and is used for benchmarking super resolution models.

    Instead of writing the code from scratch to calculate each of the metrics, we are using the TF-GAN library to evaluate our GAN implementation with ease for FID and Inception Scores. Then we make use of the `tf.image` module to calculate PSNR values for evaluating the super resolution algorithm.

    Why do we need the TF-GAN library for evaluation?

    Standard evaluation metrics for GANs such as Inception Scores, Frechet Distance or Kernel Distance are available inside TF-GAN Evaluation. Various implementations of such metrics can be prone to errors and this can result in unreliable evaluation scores. By using TF-GAN, such errors can be avoided and GAN evaluations can be made easy. For evaluating the ESRGAN model we have made use of the Inception Score (tfgan.eval.inception_score) and Frechet Distance Score (tfgan.eval.frechet_inception_distance) from the TF-GAN library.


    Here is how we use tf-gan for evaluation in code.

    First we need to install the tf-gan library which should have been part of the imports at the beginning of the notebook. Then we import the library.

    !pip install tensorflow-gan
    import tensorflow_gan as tfgan

    Now we are ready to use the library for the ESRGAN evaluation!

    Fréchet inception distance (FID)

    PYTHON
    @tf.function
    def get_fid_score(real_image, gen_image):
    size = tfgan.eval.INCEPTION_DEFAULT_IMAGE_SIZE

    resized_real_images = tf.image.resize(real_image, [size, size], method=tf.image.ResizeMethod.BILINEAR)
    resized_generated_images = tf.image.resize(gen_image, [size, size], method=tf.image.ResizeMethod.BILINEAR)
    num_inception_images = 1
    num_batches = Params['batch_size'] // num_inception_images
    fid = tfgan.eval.frechet_inception_distance(resized_real_images, resized_generated_images, num_batches=num_batches)
    return fid
    Inception Scores
    PYTHON
    @tf.function
    def get_inception_score(images, gen, num_inception_images = 8):
    size = tfgan.eval.INCEPTION_DEFAULT_IMAGE_SIZE
    resized_images = tf.image.resize(images, [size, size], method=tf.image.ResizeMethod.BILINEAR)

    num_batches = Params['batch_size'] // num_inception_images
    inc_score = tfgan.eval.inception_score(resized_images, num_batches=num_batches)

    return inc_score
    Peak Signal-to- Noise Ratio (PSNR)
    PYTHON
    def get_psnr(real, generated):
    psnr_value = tf.reduce_mean(tf.image.psnr(generated, real, max_val=256.0))
    return psnr_value

    GSoC experience

    Here is the Google Summer of Code 2021 experience in our own words:

    Nived

    As a student, Google Summer of Code gave me an opportunity to participate in exciting open source projects for TensorFlow and the mentorship that I got during this period was invaluable. I got to learn a lot about implementing various GAN models, writing tutorial notebooks, using Cloud TPUs for training models and using tools such as Google Cloud Platform. I received a lot of support from Margaret and Joel throughout the program which kept the project on track. From the beginning their suggestions helped define the project scope and during the coding period, Margaret and I met on a weekly basis to clear all my doubts and solve various issues that I was facing. Joel also helped in reviewing all the PRs made to the TF-GAN library. GSoC is indeed a great way of getting involved with various interesting TensorFlow libraries and I look forward to continuing making valuable contributions to the community.

    Margaret

    As the project mentor, I have been involved since the project selection phase. Mentoring Nived and collaborating with Joel on TF-GAN has been a fulfilling experience. Nived has done an excellent job implementing the ESRGAN paper with TensorFlow 2 and TF-GAN. Nived and I spent a lot of time looking at the various text-to-image GANs to choose one that can potentially be implemented during the GSoC timeframe. Aside from writing the ESRGAN tutorial, he made great progress on ControlGAN for text-to-image generation. I hope this project helps others to learn how to use the TF-GAN library and contribute to TF-GAN and other open source TensorFlow projects.

    Joel

    As an unofficial technical mentor, I was impressed how independently and effectivly Nived worked. I felt more like I was working with a junior colleague than an intern, in that I helped give technical and project pointers, but ultimately Nived made the decisions. I think the impressive results reflect this: Nived owned the project, and I think as a result the example and Colab are more well-written and cohesive than they otherwise might have been. Furthermore, Nived successfully navigated the multi-timezone reality that is working-from-home!

    What’s next

    During the GSoC coding period the implementation of the ESRGAN model was completed and the Python code and Colab notebooks were merged to the TF-GAN repo. The implementation of the ControlGAN model for text-to-image generation is still in progress. Once the implementation of ControlGAN is completed, we plan to extend it to serve some real-world applications in areas such as art generation or image editing. We are also planning to write tutorials to explore different models that solve the task of text-to-image translation.

    If you want to contribute to TF-GAN, you can reach out to `[email protected]` to propose a project or addition. Unless you've contributed to OSS Google projects before, it's usually a good idea to check with someone before submitting a large pull request. We look forward to seeing your contributions and working with you!

    Acknowledgements

    We would like to thank the GSoC program committee and their support, in particular Josh Gordon from the TensorFlow team.

    Many thanks to the support of the Machine Learning (ML) Google Developer Expert (GDE) program, Google Cloud Platform and TensorFlow Research Cloud.

    Vollständiger Original-Bericht
    Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf blog.tensorflow.org.
    ↗ Original-Artikel auf blog.tensorflow.org lesen
    Wie bewertest du diesen Beitrag?
    1 Klick Feedback
    Teilen mit Netzwerk & Team:

    Community-Analysen & Experten-Meinungen 0

    Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
    Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
    Community Pulse: Relevanz-Einschätzung
    1 Klick Experten-Votum
    🔴 Akute Relevanz 0%
    🟡 In Evaluierung 0%
    🟢 Keine Auswirkung 0%
    Spannende Innovation 0%
    Verwandte Story-Cluster & Quellen (Vektor-KI)
    Port 8095 Engine
    3 Quellen
    GPT-6 Astra Release Today? OpenAI’s Next Major AI Model Is Almost Here
    1 Quelle
    Apple accuses OpenAI of destroying evidence as trade-secrets fight intensifies
    1 Quelle
    Major AI platforms go down in unprecedented simultaneous outage
    Ähnliche Beiträge
    🔍 Verwandte News

    Auch interessante Nachrichten Our Summer of Code Project on TF-GAN

    Thematisch verwandte Begriffe: Summer, Code, Project, TFGAN · 6 Treffer

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...