Overview

13 New developments and challenges in text-to-image generation

The chapter offers a concise tour of how modern text-to-image systems convert language into compelling visuals, tracing the arc from early transformer-based tokenization to today’s diffusion-driven approaches. It highlights the DALL·E series and its improvements in text-image alignment and instruction following, Google’s Imagen with T5-XXL text encoders and cascaded diffusion for progressive refinement, and latent diffusion models such as Stable Diffusion and MidJourney, which generate in a compressed latent space to lower compute while empowering iterative, collaborative creative workflows.

It then examines the field’s core challenges and societal risks. Technically, models still struggle with geometric consistency due to weak 3D priors and limited understanding of physics, while training and deployment demand significant computation with environmental costs. Societally, misuse—especially deepfakes and misinformation—raises ethical and legal concerns, alongside unresolved questions about copyright and fair use in web-scale training data. The chapter also underscores the importance of bias auditing and mitigation, warning that both under- and over-correction can misrepresent people and contexts. Progress, it argues, requires better alignment, robust evaluation, and multidisciplinary governance.

To pair innovation with safeguards, the chapter presents a practical blueprint for detecting AI-generated images by fine-tuning ResNet-50. Instead of training from scratch, it builds a balanced real-versus-fake dataset, applies the pretrained model’s transforms, replaces the classification head with a two-class output, freezes the backbone, and trains the new head with early stopping before testing on unseen images. The resulting detector attains strong accuracy, offering a resource-efficient approach to deepfake identification and equipping readers with a dual perspective: how to create powerful generators and how to evaluate and defend against the risks they introduce.

The architecture of ResNet-50. ResNet-50 is structured as follows: (1) An initial convolutional layer followed by max pooling to reduce spatial dimensions; (2) Four sequential “residual blocks” composed of bottleneck units with residual connections; (3) An average pooling layer; (4) A fully connected output layer. The model takes an image as input and outputs logits for 1,000 object classes, which can be converted into predicted probabilities using the softmax activation function.
Training from scratch vs. fine-tuning an existing model. Training from scratch (top row in the diagram) involves building a model with randomly initialized parameters, requiring the network to learn all features from raw data. In contrast, fine-tuning uses the architecture and pretrained weights of an existing model, modifying (often only) the output layer for a new downstream task. The bulk of the network retains the learned parameters, while only the final layers are updated for the new objective.
Modified ResNet-50 architecture for deepfake detection. All original layers of ResNet-50 are retained, except for the last fully connected output layer. The original output head (with 1,000 output channels) is replaced with a new head (with 2 output channels), producing logits for the “real” and “fake” classes. Parameters in the new output layer are initialized randomly and trained on our dataset. All other parameters are inherited from the pretrained model and kept frozen during fine-tuning.
Using ResNet-50 to make predictions on images. Each image is shown with its top predicted class and the corresponding probability as determined by ResNet-50. The results highlight both the strengths and quirks of large-scale classification models: for example, the model may predict “bee eater” for a bird image that looks like a kingfisher, since “kingfisher” isn’t among the 1,000 ImageNet classes. Such observations show that the model’s predictions depend not only on the input image, but also on the set of categories it was trained to recognize.
Sample real and fake images from the 140k Real and Fake Faces dataset. The top row displays five real face images, while the bottom row shows five face images generated by AI. At a glance, both sets look convincingly realistic. This side-by-side comparison highlights the subtlety of the deepfake detection challenge: to the naked eye, even AI-generated images can appear authentic. Such visualizations emphasize the need for advanced machine learning methods to distinguish between real and fake images.
Using the fine-tuned model to differentiate real images from deepfakes. Each image is labeled with both its ground-truth class (real or fake) and the model’s prediction. This side-by-side visualization provides immediate feedback on the model’s predictions. Notice how convincingly realistic some “fake” images appear, underscoring the importance of robust deep learning solutions.

Summary

  • The DALL-E series harness the combined strengths of transformer architectures and advanced image generation techniques. Each successive version of DALL-E has pushed the boundaries of what’s achievable in generating images from textual descriptions.
  • Imagen combines pretrained language models with advanced cascaded diffusion architectures, generating remarkably precise, high-resolution images directly from sophisticated and nuanced textual descriptions.
  • Latent diffusion models such as Stable Diffusion have emerged as a powerful paradigm in text-to-image generation by substantially reducing computational costs while maintaining visual quality and semantic fidelity. MidJourney extends the core capabilities of Stable Diffusion into user-friendly, creatively empowering applications.
  • Despite remarkable progress, state-of-the-art text-to-image generation models still have many challenges and concerns. These include geometric inconsistency and the societal risks posed by misinformation, bias, and copyright concerns.
  • Training from scratch involves building a model with randomly initialized parameters, requiring the network to learn all features from raw data. In contrast, fine-tuning uses the architecture and pretrained weights of an existing model, modifying (often only) the output layer for a downstream task. The bulk of the network retains the learned parameters, while only the final layers are updated for the new objective.
  • Fine-tuning a neural network requires high-quality, well-labeled data that closely matches your target task. For our deepfake detection problem, this means gathering and organizing a large number of images, clearly labeled as either “real” or “fake.” The more representative and diverse the dataset, the better the model will be at generalizing to new, unseen images.
  • The fine-tuned ResNet-50 model performs well on unseen, out-of-sample images, achieving an accuracy of 93.73% among a test dataset.

FAQ

How do today’s leading text-to-image systems differ (DALL-E, Imagen, Stable Diffusion, MidJourney)? DALL-E evolved from a transformer that predicted image tokens (via VQVAE) to DALL-E 2’s CLIP-guided approach for better text-image alignment, and DALL-E 3’s stronger instruction following through improved caption-aware training. Google’s Imagen encodes text with T5-XXL and uses a cascaded diffusion pipeline that refines from 64x64 up to 1024x1024 for exceptional photorealism. Stable Diffusion operates in a compressed latent space (latent diffusion), cutting compute while retaining quality. MidJourney builds on the latent diffusion paradigm but focuses on user experience: prompt guidance, interactive refinement, collaboration, and rich stylistic controls.
What is the “geometric inconsistency” problem, and why do models struggle with it? Most models are trained on 2D images without explicit 3D structure or physical constraints, so they learn correlations rather than true 3D reasoning. As a result, perspective, depth, lighting, and object relationships can be inconsistent across a scene or viewpoints. Improving geometric consistency likely requires 3D-aware priors (e.g., multi-view supervision), depth or normal cues, or explicit physics/geometry components that enforce spatial coherence.
What are the computational and environmental concerns with state-of-the-art models? Training and serving large text-to-image models require substantial compute and energy, raising cost and sustainability questions. Mitigations include: - Using more efficient architectures (e.g., latent diffusion) - Transfer learning and fine-tuning instead of training from scratch - Pruning, quantization, and other compression techniques - Careful inference optimizations and hardware-aware deployment The goal is to reduce footprint while maintaining quality.
How can text-to-image models be misused, and what safeguards does the chapter explore? They can be used to create deepfakes and misleading content that undermines trust and public discourse. The chapter emphasizes responsible use, content moderation, and collaboration across developers, policymakers, and media. Practically, it walks through fine-tuning a ResNet-50 classifier to distinguish real from AI-generated images as a defensive measure.
What legal and copyright issues arise from training on web-scraped data? Training data often includes copyrighted material obtained without explicit consent, prompting debates over ownership and fair use. Supporters argue training is transformative; critics argue it exceeds fair use due to scale and direct ingestion. The chapter notes the issue remains unresolved and likely requires legislative and judicial guidance to balance the interests of creators, users, and developers.
Why fine-tune ResNet-50 for deepfake detection instead of training from scratch? Fine-tuning leverages rich visual features learned from large datasets like ImageNet, drastically reducing data, time, and compute needs. The approach in the chapter: - Load a pretrained ResNet-50 - Replace the final fully connected layer with a 2-class head (real vs fake) - Freeze the rest of the network - Train only the new head on a real/fake dataset This yields strong performance with minimal resources.
Which dataset and preprocessing pipeline are used in the chapter’s detector? The 140k Real and Fake Faces dataset from Kaggle (balanced: 70k real, 70k fake) with train/validation/test splits. Images are resized and normalized to ResNet-50’s expected input (3×224×224) using torchvision’s default ResNet-50 transforms. DataLoaders batch and shuffle samples for efficient training and evaluation.
What is the training setup (loss, optimizer, regularization, early stopping)? - Loss: CrossEntropyLoss for two classes - Optimizer: Adam (lr≈1e-3) - Strategy: Freeze all pretrained layers; train only the new head - Regularization: Dropout in the new head; validation monitoring - Early stopping: Stop if validation loss doesn’t improve for 3 consecutive epochs; keep best weights This balances speed, stability, and generalization.
How well did the fine-tuned model perform, and how should results be evaluated? On the provided test set (balanced real/fake), the fine-tuned ResNet-50 achieved roughly 94% accuracy in the chapter’s run. Accuracy is appropriate for balanced data, but in other settings consider confusion matrices, precision/recall, F1, ROC–AUC, and calibration. It’s also important to test robustness to new generators and distribution shifts, not just the dataset used for fine-tuning.
What remaining challenges should practitioners keep in mind? - Bias: Models can reflect or amplify social biases; auditing and mitigation are essential, while avoiding overcorrection that distorts facts. - Detection arms race: As generators improve, detectors must be updated and validated on new data. - Geometry and realism: Better 3D/physics priors are needed for consistent scenes. - Governance: Clear policies, consent practices, and responsible-release norms remain crucial as capabilities advance.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Build a Text-to-Image Generator (from Scratch) ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Build a Text-to-Image Generator (from Scratch) ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Build a Text-to-Image Generator (from Scratch) ebook for free