<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.selur.net/index.php?action=history&amp;feed=atom&amp;title=Vapoursynth_CodeFormer</id>
	<title>Vapoursynth CodeFormer - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.selur.net/index.php?action=history&amp;feed=atom&amp;title=Vapoursynth_CodeFormer"/>
	<link rel="alternate" type="text/html" href="https://wiki.selur.net/index.php?title=Vapoursynth_CodeFormer&amp;action=history"/>
	<updated>2026-11-19T06:27:10Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.2</generator>
	<entry>
		<id>https://wiki.selur.net/index.php?title=Vapoursynth_CodeFormer&amp;diff=494&amp;oldid=prev</id>
		<title>Selur: New filter page (via create-page on MediaWiki MCP Server)</title>
		<link rel="alternate" type="text/html" href="https://wiki.selur.net/index.php?title=Vapoursynth_CodeFormer&amp;diff=494&amp;oldid=prev"/>
		<updated>2026-11-16T08:48:30Z</updated>

		<summary type="html">&lt;p&gt;New filter page (via create-page on MediaWiki MCP Server)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;div style=&amp;quot;float:right; margin:0 0 1em 1em;&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;CodeFormer&amp;#039;&amp;#039;&amp;#039; is a blind face restoration network: it finds the faces in each frame, rebuilds them from a learned codebook and pastes them back, optionally while upscaling the whole frame. It runs on an NVIDIA GPU through PyTorch.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Filtering → Vapoursynth → Other&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Vapoursynth_CodeFormer.png|none|CodeFormer controls in Hybrid]]&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
Faces are detected, cropped and aligned, replaced by a reconstruction and blended back into the frame. The network invents plausible detail rather than recovering the real one, so faces can look different from the person and can flicker from frame to frame. With &amp;#039;&amp;#039;Scale&amp;#039;&amp;#039; above 1 the rest of the frame is upscaled as well. For a temporally steadier result see [[Vapoursynth FaceRestore|FaceRestore]].&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
* Windows, Hybrid&amp;#039;s torch add-on and an NVIDIA GPU with CUDA.&lt;br /&gt;
* The dlib detector is only listed when dlib is installed.&lt;br /&gt;
&lt;br /&gt;
== Settings ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Control !! Parameter !! Range / values !! Hybrid default !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| Scale || upscale || 1 – 16 || 1 || Upscale factor of the output.&lt;br /&gt;
|-&lt;br /&gt;
| Detector || detector || retinaface, dlib || retinaface || Face detector.&lt;br /&gt;
|-&lt;br /&gt;
| Weight || weight || 0 – 1 || 0.5 || Low values give prettier faces from the codebook, high values stay closer to the input.&lt;br /&gt;
|-&lt;br /&gt;
| Only center || only_center_face || on/off || off || Restores only the face nearest the center.&lt;br /&gt;
|-&lt;br /&gt;
| Streams || num_streams || 1 – 16 || 1 || Number of CUDA streams; not more than VapourSynth&amp;#039;s thread count.&lt;br /&gt;
|-&lt;br /&gt;
| Device || device_index || 0 – 4 || 0 || CUDA device.&lt;br /&gt;
|-&lt;br /&gt;
| Upscaler || bg_clip || Bilinear, Bicubic, Point, Lanczos, Spline16, Spline36, Spline64, NNEDI3, RealESRGAN (general), FeMaSR (2x), FeMaSR (4x) || Bilinear || Only with Scale above 1: how the background is upscaled. Bilinear lets the plugin do it; the network upscalers are listed only when installed.&lt;br /&gt;
|-&lt;br /&gt;
| Adjuster || – || Bilinear, Bicubic, Point, Lanczos, Spline16, Spline36, Spline64 || Bicubic || Only with Scale above 1: resizer used after the filter.&lt;br /&gt;
|-&lt;br /&gt;
| Undo upscale || – || on/off || on || On: the result is scaled back to the input size with the Adjuster. Off: the larger size is kept and only reduced to the resize resolution if it is larger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
Default settings on a 10-bit YUV 4:2:0 source (640x356):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# changing range from limited to full range for vsCodeFormer&lt;br /&gt;
clip = core.resize.Bicubic(clip, format=vs.YUV420P10, range_in_s=&amp;quot;limited&amp;quot;, range_s=&amp;quot;full&amp;quot;)&lt;br /&gt;
# setting color range to PC (full) range.&lt;br /&gt;
prop_name = &amp;#039;_Range&amp;#039; if core.core_version.release_major &amp;gt;= 74 else &amp;#039;_ColorRange&amp;#039;&lt;br /&gt;
clip = core.std.SetFrameProps(clip=clip, **{prop_name: vs.RANGE_FULL})&lt;br /&gt;
# adjusting color space from YUV420P10 to RGB24 for vsCodeFormer&lt;br /&gt;
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s=&amp;quot;470bg&amp;quot;, range_in_s=&amp;quot;full&amp;quot;, dither_type=&amp;quot;error_diffusion&amp;quot;, range_s=&amp;quot;full&amp;quot;)&lt;br /&gt;
# Blind Face Restoration using CodeFormer&lt;br /&gt;
for folder in (&amp;quot;F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/nvidia/cuda_runtime/bin&amp;quot;, &amp;quot;F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/nvidia/cublas/bin&amp;quot;):&lt;br /&gt;
  if os.path.isdir(folder): os.add_dll_directory(folder)&lt;br /&gt;
from vscodeformer import codeformer as CodeFormer&lt;br /&gt;
clip = CodeFormer(clip, upscale=1) # 640x356&lt;br /&gt;
# adjusting output color from RGB24 to YUV420P10 for NVEncModel&lt;br /&gt;
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s=&amp;quot;470bg&amp;quot;, range_in_s=&amp;quot;full&amp;quot;, range_s=&amp;quot;full&amp;quot;)&lt;br /&gt;
# changing range from full to limited range for matching filter target luma scale&lt;br /&gt;
clip = core.resize.Bicubic(clip, format=vs.YUV420P10,range_in_s=&amp;quot;full&amp;quot;, range_s=&amp;quot;limited&amp;quot;)&lt;br /&gt;
# setting color range to TV (limited) range.&lt;br /&gt;
prop_name = &amp;#039;_Range&amp;#039; if core.core_version.release_major &amp;gt;= 74 else &amp;#039;_ColorRange&amp;#039;&lt;br /&gt;
clip = core.std.SetFrameProps(clip=clip, **{prop_name: vs.RANGE_LIMITED})&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How Hybrid calls it ==&lt;br /&gt;
* The clip is converted to 8-bit RGB, full range.&lt;br /&gt;
* Scale is always written; the other options only when they differ from the defaults.&lt;br /&gt;
* For an Upscaler other than Bilinear, Hybrid builds a background clip at the final size and passes it to the filter; RealESRGAN and FeMaSR backgrounds run on the selected device.&lt;br /&gt;
* CodeFormer also offers the [[Vapoursynth common filter options|common options]] (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
=== CodeFormer ===&lt;br /&gt;
CodeFormer (Zhou et al., NeurIPS 2022) treats face restoration as a lookup in a discrete codebook of high-quality face parts: a transformer predicts the codebook entries from the degraded face. A fidelity weight balances between the codebook result and the input.&lt;br /&gt;
&lt;br /&gt;
=== vs-codeformer ===&lt;br /&gt;
HolyWu&amp;#039;s vs-codeformer runs CodeFormer in VapourSynth with PyTorch. It accepts 8-bit RGB only; a background clip has to be 8-bit RGB at exactly &amp;#039;&amp;#039;Scale&amp;#039;&amp;#039; × the input size.&lt;br /&gt;
&lt;br /&gt;
== Sources ==&lt;br /&gt;
* [https://github.com/HolyWu/vs-codeformer vs-codeformer]&lt;br /&gt;
* [https://github.com/sczhou/CodeFormer CodeFormer]&lt;br /&gt;
* Hybrid&amp;#039;s tooltips&lt;br /&gt;
&lt;br /&gt;
[[Category:Vapoursynth Filters]]&lt;/div&gt;</summary>
		<author><name>Selur</name></author>
	</entry>
</feed>