คู่มือ AI แบบเห็นภาพ

ESRGAN และ GAN สุดยอดความละเอียด

ESRGAN (Enhanced Super-Resolution Generative Adversarial Network) เป็นโมเดลจากปี 2018 ที่ขยายภาพขึ้นสี่เท่าพร้อมทั้งสร้างพื้นผิวที่คมชัดและดูสมจริง โดยใช้ตัวสร้าง (generator) ที่ฝึกฝนร่วมกับตัวจำแนก (discriminator)

ฟังคำแนะนำนี้บรรยายโดย AI · ~8 min

บนหน้านี้อ่าน 9 นาที
  1. ภาพรวม
  2. ประเด็นสำคัญ
  3. เจาะลึก
  4. การตรวจสอบว่าตัวอัปสเกลสร้างรายละเอียดเพิ่มขึ้นมากแค่ไหน
  5. การใช้งานจริงในโลกแห่งความเป็นจริง
  6. อนาคตของ ESRGAN และ GAN Super-Resolution
  7. การนำไปปฏิบัติ
  8. ที่มาและอ่านเพิ่มเติม
  9. สำรวจต่อไป
  10. คำถามที่พบบ่อย

ภาพรวม

โมเดลนี้และผู้สืบทอดอย่าง Real-ESRGAN กลายเป็นตัวอัปสเกลโอเพนซอร์กมาตรฐาน แต่รายละเอียดที่เพิ่มเข้ามานั้นเป็นการคาดเดาที่สมเหตุสมผล ไม่ใช่ข้อมูลที่กู้คืนมาได้

ประเด็นสำคัญ

  1. ESRGAN ซึ่งเผยแพร่ในเดือนกันยายน 2018 ทำการอัปสเกลภาพขึ้นสี่เท่าโดยใช้ตัวสร้างที่ฝึกฝนร่วมกับตัวจำแนกแบบสัมพัทธ์ (relativistic discriminator) เพื่อสร้างพื้นผิวที่สมจริง
  2. ESRGAN พัฒนาต่อยอดจาก SRGAN ปี 2016 ด้วยบล็อก Residual-in-Residual Dense Blocks, ไม่มี batch normalization และใช้ perceptual loss กับฟีเจอร์ VGG ก่อนการเปิดใช้งาน (activation)
  3. Real-ESRGAN จากปี 2021 สามารถจัดการกับภาพถ่ายในโลกจริงได้โดยการฝึกฝนกับภาพสังเคราะห์ที่ทำให้เสื่อมคุณภาพด้วยการเบลอ สัญญาณรบกวน การปรับขนาด และการบีบอัด JPEG แบบสุ่ม
  4. Blau และ Michaeli พิสูจน์ไว้ในปี 2018 ว่าความสมจริงด้านการรับรู้และความแม่นยำของพิกเซลขัดแย้งกัน ดังนั้น ภาพที่อัปสเกลแล้วดูคมชัดขึ้นจึงไม่ได้แปลว่ามีความแม่นยำมากขึ้น
  5. รายละเอียดที่เพิ่มเข้ามาโดยตัวอัปสเกล GAN ถูกสร้างขึ้นมาจากข้อมูลฝึกฝน ดังนั้นจึงไม่ควรใช้ภาพที่อัปสเกลแล้วเป็นหลักฐานทางนิติวิทยาศาสตร์หรือทางกฎหมาย

เจาะลึก

Super-resolution is the task of producing a larger, sharper image from a smaller one. When an image is shrunk, fine detail such as hair, fabric weave or text strokes is thrown away, and many different high-resolution images shrink to the same small one. A super-resolution model therefore cannot recover the original detail with certainty; it has to choose a plausible version. GAN super-resolution, short for generative adversarial network super-resolution, makes that choice by training the model to produce output that looks like a real photograph. ESRGAN, the Enhanced Super-Resolution Generative Adversarial Network, is the best-known model of this kind, and it typically enlarges images by a factor of four in each direction.

The method works in steps. First, training pairs are made by taking high-resolution images and shrinking them, so the model learns to map small inputs to their known large versions. Second, a generator network, a deep stack of convolutional layers, takes the small image and outputs a large one. Third, its output is scored by several losses: a pixel loss that keeps colors and layout close to the target, a perceptual loss that compares features extracted by a pretrained image-recognition network called VGG, and an adversarial loss. Fourth, the adversarial loss comes from a second network, the discriminator, which is trained at the same time to tell generated images from real ones. As the discriminator improves at spotting smooth, fake-looking output, the generator is pushed to produce crisp textures that pass as real.

The idea came from SRGAN, posted by Christian Ledig and colleagues in September 2016 and presented at CVPR 2017. Before it, most super-resolution models minimized mean squared error against the target, which scores well on PSNR, a pixel-accuracy metric, but produces blurry results because averaging many plausible textures yields a smear. SRGAN replaced that with a perceptual loss plus adversarial loss and reported that human raters in a mean-opinion-score study judged its four-times upscales closer to the originals than any other method tested. ESRGAN, posted in September 2018 by Xintao Wang and colleagues from the Chinese University of Hong Kong, SenseTime and partner institutes, and presented at an ECCV 2018 workshop, improved SRGAN in three ways. It replaced the basic block with a Residual-in-Residual Dense Block and removed batch normalization, it used a relativistic discriminator that judges whether a real image looks more realistic than generated ones on average, and it computed perceptual loss on VGG features before their activation function, which the authors say gives sharper edges and more accurate brightness.

Real-ESRGAN, posted in July 2021 by Wang, Liangbin Xie, Chao Dong and Ying Shan, tackled ESRGAN's biggest practical weakness. ESRGAN was trained on clean images shrunk with a simple bicubic filter, so it handled real photos poorly, because real low-quality images also carry blur, sensor noise, JPEG compression and resizing artifacts. Real-ESRGAN trains only on synthetic data but generates it with a high-order degradation model that applies blur, resizing, noise and compression in randomized sequences, sometimes twice, and it adds a U-Net discriminator with spectral normalization to keep training stable. Its open-source release added specialized anime models, a lightweight general model with adjustable denoising, and portable executables.

The obvious alternatives each make a different trade. Classic interpolation such as bicubic resizing is fast and invents nothing, but looks soft. Models trained only on pixel loss give higher PSNR scores but blurrier results. Blau and Michaeli proved in a CVPR 2018 paper, The Perception-Distortion Tradeoff, that the two goals conflict: below a certain level of average distortion, outputs necessarily become easier to tell apart from real images, and this holds for any distortion measure. GAN models deliberately sit at the realistic end of that trade-off. ESRGAN's authors offer a dial between the two, network interpolation, which blends the weights of a PSNR-trained model and a GAN-trained model so a user can choose how much texture to hallucinate.

The central limitation is that the added detail is invented. A GAN upscaler fills in texture that fits patterns in its training data, so it can draw convincing but wrong eyelashes, letters, bricks or license-plate digits. The risk becomes concrete with faces. In June 2020 a demo of PULSE, a CVPR 2020 face upsampling method that searches a generative model for realistic faces that shrink down to the input, turned a pixelated photo of Barack Obama into a white man's face, as recounted by The Gradient. The PULSE paper itself describes producing images that downscale correctly rather than recovering the original. For that reason, GAN-upscaled images should not be treated as evidence in forensic, medical or legal settings. The Real-ESRGAN paper lists its own failure modes: twisted lines caused by aliasing in building and indoor scenes, GAN artifacts on some images, and real-world degradations outside its training distribution that are not removed and may even be amplified. Tiling adds another, visible seams when large images are processed in tiles, a problem the Real-ESRGAN repository explicitly warns about.

In practice, using an ESRGAN-family model is inexpensive. Pretrained weights are freely available, Real-ESRGAN is released under the BSD-3-Clause license, and its portable executables run on consumer GPUs from all three major vendors. Large images are split into tiles to fit GPU memory. Training a new model is more demanding: ESRGAN trained on the DIV2K, Flickr2K and OutdoorSceneTraining datasets using 128 by 128 pixel high-resolution crops, and GAN training needs careful loss weighting to avoid unstable results. The right choice depends on purpose. For viewing pleasure, such as enlarging artwork or old photos, realistic invented texture is usually the goal; for anything where the exact pixels matter, a fidelity-oriented model or simple interpolation is the honest option.

04ตัวอย่างการทำงาน

การตรวจสอบว่าตัวอัปสเกลสร้างรายละเอียดเพิ่มขึ้นมากแค่ไหน

  1. เลือกภาพถ่ายที่คมชัดและมีข้อความขนาดเล็กที่อ่านได้ ตัวอย่างเช่น ภาพป้ายถนนขนาด 1,024 คูณ 1,024 พิกเซล

  2. ย่อขนาดลงสี่เท่าเหลือ 256 คูณ 256 พิกเซลด้วยการปรับขนาดแบบบิคิวบิก เพื่อให้ข้อความอ่านไม่ออก

  3. ขยายภาพขนาดเล็กนั้นขึ้นสี่เท่าด้วยการปรับขนาดแบบบิคิวบิกธรรมดาและบันทึกผลลัพธ์

  4. ขยายภาพขนาดเล็กภาพเดิมด้วยโมเดล RealESRGAN_x4plus ของ Real-ESRGAN และบันทึกผลลัพธ์นั้น

  5. เปรียบเทียบผลลัพธ์ทั้งสองแบบเคียงคู่กับภาพต้นฉบับ โดยซูมเข้าไปที่ข้อความและพื้นผิวละเอียด

  6. คำนวณค่า PSNR สำหรับผลลัพธ์แต่ละรายการเทียบกับต้นฉบับ โดยใช้ฟังก์ชัน PSNR ของไลบรารีรูปภาพใดก็ได้

มันแสดงให้เห็นอะไร

ผลลัพธ์จาก Real-ESRGAN มักจะดูคมชัดกว่ามาก ในขณะที่ผลลัพธ์จากบิคิวบิกจะดูนุ่มนวล แต่ตัวอักษรในผลลัพธ์จาก GAN อาจมีรูปร่างที่ผิดเพี้ยน การเปรียบเทียบ PSNR แสดงให้เห็นว่าภาพที่คมชัดกว่านั้นเข้าใกล้ต้นฉบับจริงๆ หรือไม่ ซึ่งเป็นการแสดงให้เห็นถึงการแลกเปลี่ยนระหว่างการรับรู้และความบิดเบือน

การใช้งานจริงในโลกแห่งความเป็นจริง

การขยายภาพถ่ายและงานศิลปะด้วยโปรเจกต์โอเพนซอร์ส Real-ESRGAN ซึ่งมีโมเดลเริ่มต้นอย่าง RealESRGAN_x4plus ที่ช่วยขยายภาพได้ถึงสี่เท่า และมีที่เก็บข้อมูล GitHub ที่มียอดดาวมากกว่า 37,000 ครั้ง

การขยายภาพประกอบอนิเมะและวิดีโออนิเมะด้วยโมเดล RealESRGAN_x4plus_anime_6B และ realesr-animevideov3 โดยเฉพาะของ Real-ESRGAN ซึ่งปรับแต่งมาสำหรับภาพสีแบนๆ และลายเส้น

การรันการขยายภาพบนเครื่อง Windows, Linux หรือ macOS ทั่วไป ด้วยไฟล์เรียกใช้งาน ncnn-vulkan แบบพกพาของ Real-ESRGAN ซึ่งทำงานบน GPU ของ Intel, AMD และ Nvidia ได้โดยไม่ต้องติดตั้ง CUDA หรือ PyTorch

การฟื้นฟูใบหน้าในภาพถ่ายเก่าหรือคุณภาพต่ำโดยการผสาน Real-ESRGAN สำหรับพื้นหลังเข้ากับตัวเลือก --face_enhance ซึ่งจะเรียกใช้โมเดลฟื้นฟูใบหน้า GFPGAN แยกต่างหาก

การประเมินคุณภาพเชิงการรับรู้: ESRGAN ชนะรางวัลในหมวด 3 ของการแข่งขัน PIRM2018-SR ซึ่งเป็นการแข่งขันที่จัดอันดับวิธีซูเปอร์เรโซลูชันด้วยดัชนีเชิงการรับรู้แบบไม่ต้องอ้างอิงต้นฉบับ แทนที่จะใช้ความแม่นยำของพิกเซล

อนาคตของ ESRGAN และ GAN Super-Resolution

The core tension in this field, formalized in Blau and Michaeli's 2018 perception-distortion result, has not gone away: any upscaler that looks more realistic must, past a point, drift further from the true image on average. Research since ESRGAN has largely focused on the input side, as Real-ESRGAN did in 2021 by simulating realistic degradations, and on the generative engine, and on the generative engine itself. Each new method faces the same questions about how much invented detail is acceptable and how to measure quality when no single metric captures both fidelity and realism. The social questions raised by the PULSE episode in June 2020 also remain open. Face-focused upscalers inherit biases from their training data, and outputs can be mistaken for recovered evidence. Directions discussed in that debate, such as model cards documenting training data and intended use, help users judge a released model, but there is no technical fix that lets a model know detail that was never captured. Users and institutions will continue to need policies on when enhanced images may be used and how they must be labeled.

การนำไปปฏิบัติ

ทำไมมันถึงสำคัญ

  • ความเร็วและขนาด. Visual AI สามารถทำให้การตรวจสอบ การตรวจจับ และการแท็กเป็นอัตโนมัติในขนาดต่างๆ
  • สร้างทางเลือก. ทีมสร้างสรรค์สามารถสร้างต้นแบบแนวคิดได้รวดเร็วขึ้นโดยต้องมีการแก้ไขด้วยตนเองน้อยลง
  • ทีมงานและขั้นตอนการทำงาน. การดำเนินการสามารถใช้สัญญาณภาพและวิดีโอที่ก่อนหน้านี้ประมวลผลได้ยาก

ระวัง

  • สิทธิ์และความยินยอมในรูปภาพอาจกลายเป็นความเสี่ยงทางกฎหมายได้หากแหล่งที่มาไม่ชัดเจน
  • ประสิทธิภาพของโมเดลอาจแตกต่างกันไปตามสภาพแสง ข้อมูลประชากร และสภาพแวดล้อม
  • ผลบวกลวงอาจไม่สังเกตเห็นเว้นแต่จะมีการตรวจสอบเกณฑ์ความเชื่อมั่น

ขั้นตอนต่อไป

  1. กำหนดเกณฑ์การยอมรับสำหรับความแม่นยำ การเรียกคืน และต้นทุนข้อผิดพลาด
  2. ทดสอบด้วยข้อมูลที่ตรงกับเงื่อนไขการผลิตจริง
  3. เพิ่มการตรวจสอบโดยเจ้าหน้าที่สำหรับการคาดการณ์ที่มีความมั่นใจต่ำหรือมีผลกระทบสูง
  4. ติดตามการเคลื่อนตัวของโมเดลและตรวจสอบความถูกต้องอีกครั้งหลังจากการเปลี่ยนแปลงกล้องหรือชุดข้อมูล

ที่มาและอ่านเพิ่มเติม

  1. arXiv / ECCV 2018 Workshops (Wang et al.)ESRGAN: Enhanced Super-Resolution Generative Adversarial Networks
  2. arXiv / CVPR 2017 (Ledig et al.)Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network
  3. arXiv (Wang, Xie, Dong, Shan)Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data
  4. GitHubxinntao/Real-ESRGAN
  5. arXiv / CVPR 2018 (Blau, Michaeli)The Perception-Distortion Tradeoff
  6. arXiv / CVPR 2020 (Menon et al.)PULSE: Self-Supervised Photo Upsampling via Latent Space Exploration of Generative Models
  7. The Gradientบทเรียนจากโมเดล PULSE และการอภิปราย

สำรวจต่อไป

จดหมายข่าวฟรี

รับสรุป AI รายวัน

เรื่องราว AI ที่ตรวจสอบแล้ว 3 เรื่องทุกวันทำงาน เช้า, เขียนเป็นภาษาอังกฤษธรรมดา ฟรีตลอดไป ไม่มีโฆษณา

อีเมลหนึ่งฉบับทุกวันทำงาน ยกเลิกการสมัครในคลิกเดียว เราไม่เคยขายหรือแชร์ที่อยู่อีเมลของคุณ

ทดสอบตัวเอง

ทำแบบทดสอบเรื่อง ESRGAN และ GAN Super-Resolution

ข้อเสนอแนะทันทีสำหรับทุกคำตอบ และใบรับรองที่สามารถแชร์ได้พร้อม ID ที่ตรวจสอบได้เมื่อคุณผ่านหลักสูตร

เริ่มแบบทดสอบ

สนับสนุนการศึกษา AI ฟรี AI Understanding เป็นองค์กรไม่แสวงหาผลกำไร 501(c)(3) — ไม่มีโฆษณา ไม่มีกำแพงเงิน, ตลอดไป บริจาค

คำถามที่พบบ่อย

ESRGAN และ GAN Super-Resolution คืออะไร

ESRGAN (Enhanced Super-Resolution Generative Adversarial Network) คือโมเดลปี 2018 ที่ขยายภาพให้ใหญ่ขึ้นสี่เท่าพร้อมทั้งสร้างพื้นผิวที่คมชัดและดูสมจริงโดยใช้เครื่องมือสร้าง (generator) ที่ฝึกฝนร่วมกับตัวจำแนก (discriminator) โมเดลนี้และรุ่นต่อมาอย่าง Real-ESRGAN ได้กลายเป็นเครื่องมือเพิ่มความละเอียดแบบโอเพนซอร์สมาตรฐาน แต่รายละเอียดที่เพิ่มเข้ามานั้นเป็นการคาดเดาที่สมเหตุสมผล ไม่ใช่ข้อมูลที่กู้คืนมาได้

'GAN' ใน ESRGAN หมายถึงอะไร

GAN ย่อมาจาก Generative Adversarial Network ซึ่งเป็นการตั้งค่าที่ผู้สร้างและผู้เลือกปฏิบัติแข่งขันกันระหว่างการฝึกอบรม

ตัวสร้าง ESRGAN ใช้ Building Block ใดเป็นหลัก

เครื่องกำเนิดของ ESRGAN จะซ้อน Residual-in-Residual Dense Blocks (RRDB) ซึ่งเป็นหน่วยตกค้างที่เชื่อมต่ออย่างหนาแน่นเป็นโครงสร้างหลัก

เหตุใดผู้เขียนของ ESRGAN จึงลบการทำให้เป็นมาตรฐานแบบแบตช์ออกจากตัวสร้าง

ผู้เขียนพบว่าการทำให้เป็นมาตรฐานแบบแบตช์ทำให้เกิดสิ่งที่ไม่พึงประสงค์ในเอาต์พุตที่มีความละเอียดสูงมาก ดังนั้นพวกเขาจึงลบมันออกจากบล็อก RRDB

อะไรคือข้อแลกเปลี่ยนหลักที่ ESRGAN ทำเมื่อเปรียบเทียบกับวิธีการสูญเสียพิกเซลเท่านั้น

การสูญเสียฝ่ายตรงข้ามจะผลักดันเอาท์พุตไปสู่พื้นผิวที่ดูสมจริง แม้ว่าค่าพิกเซลแต่ละพิกเซลจะแตกต่างไปจากความจริงภาคพื้นดินก็ตาม

การสูญเสียการรับรู้ (VGG) ของ ESRGAN วัดได้ที่ไหน

ESRGAN คำนวณการสูญเสียการรับรู้บนแผนที่คุณลักษณะ VGG ก่อนฟังก์ชันการเปิดใช้งาน ซึ่งผู้เขียนพบว่าให้ผลลัพธ์ที่คมชัดยิ่งขึ้น

เรียนรู้ต่อไป

คำแนะนำที่เกี่ยวข้อง

คำแนะนำเพิ่มเติมที่เลือกสำหรับหัวข้อนี้

รับใบรับรอง AI ฟรีหลักสูตรและการสอบสั้น ๆ ฟรี ไม่มีค่าใช้จ่าย ไม่มีบัตรเครดิต ประมาณ 2.5 ชั่วโมงเริ่มต้นฟรี →