import{S as Rs,i as $s,s as ys,e as n,k as p,w as v,t as i,M as Ts,c as s,d as t,m as h,a as r,x as b,h as l,b as c,N as xs,G as o,g as u,y as R,q as $,o as y,B as T,v as Is,L as En}from"../../chunks/vendor-hf-doc-builder.js";import{T as bs}from"../../chunks/Tip-hf-doc-builder.js";import{D as Oe}from"../../chunks/Docstring-hf-doc-builder.js";import{C as kn}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as De}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as jn}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Ps(P){let m,S,_,f,w;return f=new kn({props:{code:`from transformers import Swin2SRConfig, Swin2SRModel

# Initializing a Swin2SR caidas/swin2sr-classicalsr-x2-64 style configuration
configuration = Swin2SRConfig()

# Initializing a model (with random weights) from the caidas/swin2sr-classicalsr-x2-64 style configuration
model = Swin2SRModel(configuration)

# Accessing the model configuration
configuration = model.config`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Swin2SRConfig, Swin2SRModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Swin2SR caidas/swin2sr-classicalsr-x2-64 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = Swin2SRConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the caidas/swin2sr-classicalsr-x2-64 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Swin2SRModel(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`}}),{c(){m=n("p"),S=i("Example:"),_=p(),v(f.$$.fragment)},l(a){m=s(a,"P",{});var g=r(m);S=l(g,"Example:"),g.forEach(t),_=h(a),b(f.$$.fragment,a)},m(a,g){u(a,m,g),o(m,S),u(a,_,g),R(f,a,g),w=!0},p:En,i(a){w||($(f.$$.fragment,a),w=!0)},o(a){y(f.$$.fragment,a),w=!1},d(a){a&&t(m),a&&t(_),T(f,a)}}}function js(P){let m,S,_,f,w;return{c(){m=n("p"),S=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=n("code"),f=i("Module"),w=i(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(a){m=s(a,"P",{});var g=r(m);S=l(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=s(g,"CODE",{});var C=r(_);f=l(C,"Module"),C.forEach(t),w=l(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(a,g){u(a,m,g),o(m,S),o(m,_),o(_,f),o(m,w)},d(a){a&&t(m)}}}function Es(P){let m,S,_,f,w;return f=new kn({props:{code:`from transformers import AutoImageProcessor, Swin2SRModel
import torch
from datasets import load_dataset

dataset = load_dataset("huggingface/cats-image")
image = dataset["test"]["image"][0]

image_processor = AutoImageProcessor.from_pretrained("caidas/swin2SR-classical-sr-x2-64")
model = Swin2SRModel.from_pretrained("caidas/swin2SR-classical-sr-x2-64")

inputs = image_processor(image, return_tensors="pt")

with torch.no_grad():
    outputs = model(**inputs)

last_hidden_states = outputs.last_hidden_state
list(last_hidden_states.shape)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, Swin2SRModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;huggingface/cats-image&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = dataset[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-string">&quot;image&quot;</span>][<span class="hljs-number">0</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;caidas/swin2SR-classical-sr-x2-64&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Swin2SRModel.from_pretrained(<span class="hljs-string">&quot;caidas/swin2SR-classical-sr-x2-64&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = image_processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(last_hidden_states.shape)
[<span class="hljs-number">1</span>, <span class="hljs-number">180</span>, <span class="hljs-number">488</span>, <span class="hljs-number">648</span>]`}}),{c(){m=n("p"),S=i("Example:"),_=p(),v(f.$$.fragment)},l(a){m=s(a,"P",{});var g=r(m);S=l(g,"Example:"),g.forEach(t),_=h(a),b(f.$$.fragment,a)},m(a,g){u(a,m,g),o(m,S),u(a,_,g),R(f,a,g),w=!0},p:En,i(a){w||($(f.$$.fragment,a),w=!0)},o(a){y(f.$$.fragment,a),w=!1},d(a){a&&t(m),a&&t(_),T(f,a)}}}function ks(P){let m,S,_,f,w;return{c(){m=n("p"),S=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=n("code"),f=i("Module"),w=i(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(a){m=s(a,"P",{});var g=r(m);S=l(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=s(g,"CODE",{});var C=r(_);f=l(C,"Module"),C.forEach(t),w=l(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(a,g){u(a,m,g),o(m,S),o(m,_),o(_,f),o(m,w)},d(a){a&&t(m)}}}function Cs(P){let m,S,_,f,w;return f=new kn({props:{code:`import torch
import numpy as np
from PIL import Image
import requests

from transformers import AutoImageProcessor, Swin2SRForImageSuperResolution

processor = AutoImageProcessor.from_pretrained("caidas/swin2SR-classical-sr-x2-64")
model = Swin2SRForImageSuperResolution.from_pretrained("caidas/swin2SR-classical-sr-x2-64")

url = "https://huggingface.co/spaces/jjourney1125/swin2sr/resolve/main/samples/butterfly.jpg"
image = Image.open(requests.get(url, stream=True).raw)
# prepare image for the model
inputs = processor(image, return_tensors="pt")

# forward pass
with torch.no_grad():
    outputs = model(**inputs)

output = outputs.reconstruction.data.squeeze().float().cpu().clamp_(0, 1).numpy()
output = np.moveaxis(output, source=0, destination=-1)
output = (output * 255.0).round().astype(np.uint8)  # float32 to uint8
# you can visualize \`output\` with \`Image.fromarray\``,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, Swin2SRForImageSuperResolution

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;caidas/swin2SR-classical-sr-x2-64&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Swin2SRForImageSuperResolution.from_pretrained(<span class="hljs-string">&quot;caidas/swin2SR-classical-sr-x2-64&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;https://huggingface.co/spaces/jjourney1125/swin2sr/resolve/main/samples/butterfly.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># prepare image for the model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># forward pass</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>output = outputs.reconstruction.data.squeeze().<span class="hljs-built_in">float</span>().cpu().clamp_(<span class="hljs-number">0</span>, <span class="hljs-number">1</span>).numpy()
<span class="hljs-meta">&gt;&gt;&gt; </span>output = np.moveaxis(output, source=<span class="hljs-number">0</span>, destination=-<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>output = (output * <span class="hljs-number">255.0</span>).<span class="hljs-built_in">round</span>().astype(np.uint8)  <span class="hljs-comment"># float32 to uint8</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># you can visualize \`output\` with \`Image.fromarray\`</span>`}}),{c(){m=n("p"),S=i("Example:"),_=p(),v(f.$$.fragment)},l(a){m=s(a,"P",{});var g=r(m);S=l(g,"Example:"),g.forEach(t),_=h(a),b(f.$$.fragment,a)},m(a,g){u(a,m,g),o(m,S),u(a,_,g),R(f,a,g),w=!0},p:En,i(a){w||($(f.$$.fragment,a),w=!0)},o(a){y(f.$$.fragment,a),w=!1},d(a){a&&t(m),a&&t(_),T(f,a)}}}function Ms(P){let m,S,_,f,w,a,g,C,et,To,q,B,no,pe,ot,so,tt,xo,j,nt,he,st,rt,ue,at,it,Le,lt,ct,Io,Ue,dt,Po,We,ro,mt,jo,J,Cn,Eo,fe,pt,Ve,ht,ko,F,ut,ge,ft,gt,_e,_t,wt,Co,z,G,ao,we,St,io,vt,Mo,Y,bt,Se,Rt,$t,Ao,X,yt,ve,Tt,xt,Fo,N,K,lo,be,It,co,Pt,qo,M,Re,jt,mo,Et,kt,Q,$e,Ct,po,Mt,zo,O,Z,ho,ye,At,uo,Ft,No,x,Te,qt,D,zt,He,Nt,Ot,xe,Dt,Lt,Ut,L,Wt,Be,Vt,Ht,Je,Bt,Jt,Gt,ee,Oo,U,oe,fo,Ie,Yt,go,Xt,Do,A,Pe,Kt,je,Qt,Ee,Zt,en,on,E,ke,tn,W,nn,Ge,sn,rn,_o,an,ln,cn,te,dn,ne,Lo,V,se,wo,Ce,mn,So,pn,Uo,I,Me,hn,vo,un,fn,Ae,gn,Fe,_n,wn,Sn,k,qe,vn,H,bn,Ye,Rn,$n,bo,yn,Tn,xn,re,In,ae,Wo;return a=new De({}),pe=new De({}),we=new De({}),be=new De({}),Re=new Oe({props:{name:"class transformers.Swin2SRImageProcessor",anchor:"transformers.Swin2SRImageProcessor",parameters:[{name:"do_rescale",val:": bool = True"},{name:"rescale_factor",val:": typing.Union[int, float] = 0.00392156862745098"},{name:"do_pad",val:": bool = True"},{name:"pad_size",val:": int = 8"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Swin2SRImageProcessor.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to rescale the image by the specified scale <code>rescale_factor</code>. Can be overridden by the <code>do_rescale</code>
parameter in the <code>preprocess</code> method.`,name:"do_rescale"},{anchor:"transformers.Swin2SRImageProcessor.rescale_factor",description:`<strong>rescale_factor</strong> (<code>int</code> or <code>float</code>, <em>optional</em>, defaults to <code>1/255</code>) &#x2014;
Scale factor to use if rescaling the image. Can be overridden by the <code>rescale_factor</code> parameter in the
<code>preprocess</code> method.`,name:"rescale_factor"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/swin2sr/image_processing_swin2sr.py#L32"}}),$e=new Oe({props:{name:"preprocess",anchor:"transformers.Swin2SRImageProcessor.preprocess",parameters:[{name:"images",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), typing.List[ForwardRef('PIL.Image.Image')], typing.List[numpy.ndarray], typing.List[ForwardRef('torch.Tensor')]]"},{name:"do_rescale",val:": typing.Optional[bool] = None"},{name:"rescale_factor",val:": typing.Optional[float] = None"},{name:"do_pad",val:": typing.Optional[bool] = None"},{name:"pad_size",val:": typing.Optional[int] = None"},{name:"return_tensors",val:": typing.Union[transformers.utils.generic.TensorType, str, NoneType] = None"},{name:"data_format",val:": typing.Union[str, transformers.image_utils.ChannelDimension] = <ChannelDimension.FIRST: 'channels_first'>"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Swin2SRImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>ImageInput</code>) &#x2014;
Image to preprocess.`,name:"images"},{anchor:"transformers.Swin2SRImageProcessor.preprocess.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_rescale</code>) &#x2014;
Whether to rescale the image values between [0 - 1].`,name:"do_rescale"},{anchor:"transformers.Swin2SRImageProcessor.preprocess.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>optional</em>, defaults to <code>self.rescale_factor</code>) &#x2014;
Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.Swin2SRImageProcessor.preprocess.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to pad the image to make the height and width divisible by <code>window_size</code>.`,name:"do_pad"},{anchor:"transformers.Swin2SRImageProcessor.preprocess.pad_size",description:`<strong>pad_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>32</code>) &#x2014;
The size of the sliding window for the local attention.`,name:"pad_size"},{anchor:"transformers.Swin2SRImageProcessor.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <code>TensorType</code>, <em>optional</em>) &#x2014;
The type of tensors to return. Can be one of:<ul>
<li>Unset: Return a list of <code>np.ndarray</code>.</li>
<li><code>TensorType.TENSORFLOW</code> or <code>&apos;tf&apos;</code>: Return a batch of type <code>tf.Tensor</code>.</li>
<li><code>TensorType.PYTORCH</code> or <code>&apos;pt&apos;</code>: Return a batch of type <code>torch.Tensor</code>.</li>
<li><code>TensorType.NUMPY</code> or <code>&apos;np&apos;</code>: Return a batch of type <code>np.ndarray</code>.</li>
<li><code>TensorType.JAX</code> or <code>&apos;jax&apos;</code>: Return a batch of type <code>jax.numpy.ndarray</code>.</li>
</ul>`,name:"return_tensors"},{anchor:"transformers.Swin2SRImageProcessor.preprocess.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>, defaults to <code>ChannelDimension.FIRST</code>) &#x2014;
The channel dimension format for the output image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li>Unset: Use the channel dimension format of the input image.</li>
</ul>`,name:"data_format"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/swin2sr/image_processing_swin2sr.py#L108"}}),ye=new De({}),Te=new Oe({props:{name:"class transformers.Swin2SRConfig",anchor:"transformers.Swin2SRConfig",parameters:[{name:"image_size",val:" = 64"},{name:"patch_size",val:" = 1"},{name:"num_channels",val:" = 3"},{name:"embed_dim",val:" = 180"},{name:"depths",val:" = [6, 6, 6, 6, 6, 6]"},{name:"num_heads",val:" = [6, 6, 6, 6, 6, 6]"},{name:"window_size",val:" = 8"},{name:"mlp_ratio",val:" = 2.0"},{name:"qkv_bias",val:" = True"},{name:"hidden_dropout_prob",val:" = 0.0"},{name:"attention_probs_dropout_prob",val:" = 0.0"},{name:"drop_path_rate",val:" = 0.1"},{name:"hidden_act",val:" = 'gelu'"},{name:"use_absolute_embeddings",val:" = False"},{name:"patch_norm",val:" = True"},{name:"initializer_range",val:" = 0.02"},{name:"layer_norm_eps",val:" = 1e-05"},{name:"upscale",val:" = 2"},{name:"img_range",val:" = 1.0"},{name:"resi_connection",val:" = '1conv'"},{name:"upsampler",val:" = 'pixelshuffle'"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Swin2SRConfig.image_size",description:`<strong>image_size</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014;
The size (resolution) of each image.`,name:"image_size"},{anchor:"transformers.Swin2SRConfig.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The size (resolution) of each patch.`,name:"patch_size"},{anchor:"transformers.Swin2SRConfig.num_channels",description:`<strong>num_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 3) &#x2014;
The number of input channels.`,name:"num_channels"},{anchor:"transformers.Swin2SRConfig.embed_dim",description:`<strong>embed_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 180) &#x2014;
Dimensionality of patch embedding.`,name:"embed_dim"},{anchor:"transformers.Swin2SRConfig.depths",description:`<strong>depths</strong> (<code>list(int)</code>, <em>optional</em>, defaults to <code>[6, 6, 6, 6, 6, 6]</code>) &#x2014;
Depth of each layer in the Transformer encoder.`,name:"depths"},{anchor:"transformers.Swin2SRConfig.num_heads",description:`<strong>num_heads</strong> (<code>list(int)</code>, <em>optional</em>, defaults to <code>[6, 6, 6, 6, 6, 6]</code>) &#x2014;
Number of attention heads in each layer of the Transformer encoder.`,name:"num_heads"},{anchor:"transformers.Swin2SRConfig.window_size",description:`<strong>window_size</strong> (<code>int</code>, <em>optional</em>, defaults to 8) &#x2014;
Size of windows.`,name:"window_size"},{anchor:"transformers.Swin2SRConfig.mlp_ratio",description:`<strong>mlp_ratio</strong> (<code>float</code>, <em>optional</em>, defaults to 2.0) &#x2014;
Ratio of MLP hidden dimensionality to embedding dimensionality.`,name:"mlp_ratio"},{anchor:"transformers.Swin2SRConfig.qkv_bias",description:`<strong>qkv_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not a learnable bias should be added to the queries, keys and values.`,name:"qkv_bias"},{anchor:"transformers.Swin2SRConfig.hidden_dropout_prob",description:`<strong>hidden_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout probability for all fully connected layers in the embeddings and encoder.`,name:"hidden_dropout_prob"},{anchor:"transformers.Swin2SRConfig.attention_probs_dropout_prob",description:`<strong>attention_probs_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_probs_dropout_prob"},{anchor:"transformers.Swin2SRConfig.drop_path_rate",description:`<strong>drop_path_rate</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
Stochastic depth rate.`,name:"drop_path_rate"},{anchor:"transformers.Swin2SRConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the encoder. If string, <code>&quot;gelu&quot;</code>, <code>&quot;relu&quot;</code>,
<code>&quot;selu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"hidden_act"},{anchor:"transformers.Swin2SRConfig.use_absolute_embeddings",description:`<strong>use_absolute_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to add absolute position embeddings to the patch embeddings.`,name:"use_absolute_embeddings"},{anchor:"transformers.Swin2SRConfig.patch_norm",description:`<strong>patch_norm</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to add layer normalization after patch embedding.`,name:"patch_norm"},{anchor:"transformers.Swin2SRConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.Swin2SRConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-12) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.Swin2SRConfig.upscale",description:`<strong>upscale</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
The upscale factor for the image. 2/3/4/8 for image super resolution, 1 for denoising and compress artifact
reduction`,name:"upscale"},{anchor:"transformers.Swin2SRConfig.img_range",description:`<strong>img_range</strong> (<code>float</code>, <em>optional</em>, defaults to 1.) &#x2014;
The range of the values of the input image.`,name:"img_range"},{anchor:"transformers.Swin2SRConfig.resi_connection",description:`<strong>resi_connection</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;1conv&quot;</code>) &#x2014;
The convolutional block to use before the residual connection in each stage.`,name:"resi_connection"},{anchor:"transformers.Swin2SRConfig.upsampler",description:`<strong>upsampler</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pixelshuffle&quot;</code>) &#x2014;
The reconstruction reconstruction module. Can be &#x2018;pixelshuffle&#x2019;/&#x2018;pixelshuffledirect&#x2019;/&#x2018;nearest+conv&#x2019;/None.`,name:"upsampler"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/swin2sr/configuration_swin2sr.py#L30"}}),ee=new jn({props:{anchor:"transformers.Swin2SRConfig.example",$$slots:{default:[Ps]},$$scope:{ctx:P}}}),Ie=new De({}),Pe=new Oe({props:{name:"class transformers.Swin2SRModel",anchor:"transformers.Swin2SRModel",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.Swin2SRModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/swin2sr#transformers.Swin2SRConfig">Swin2SRConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/swin2sr/modeling_swin2sr.py#L848"}}),ke=new Oe({props:{name:"forward",anchor:"transformers.Swin2SRModel.forward",parameters:[{name:"pixel_values",val:""},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.Swin2SRModel.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<a href="/docs/transformers/main/en/model_doc/poolformer#transformers.PoolFormerFeatureExtractor.__call__">Swin2SRImageProcessor.<strong>call</strong>()</a> for details.`,name:"pixel_values"},{anchor:"transformers.Swin2SRModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.Swin2SRModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.Swin2SRModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.Swin2SRModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/swin2sr/modeling_swin2sr.py#L897",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutput"
>transformers.modeling_outputs.BaseModelOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/swin2sr#transformers.Swin2SRConfig"
>Swin2SRConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutput"
>transformers.modeling_outputs.BaseModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),te=new bs({props:{$$slots:{default:[js]},$$scope:{ctx:P}}}),ne=new jn({props:{anchor:"transformers.Swin2SRModel.forward.example",$$slots:{default:[Es]},$$scope:{ctx:P}}}),Ce=new De({}),Me=new Oe({props:{name:"class transformers.Swin2SRForImageSuperResolution",anchor:"transformers.Swin2SRForImageSuperResolution",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.Swin2SRForImageSuperResolution.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/swin2sr#transformers.Swin2SRConfig">Swin2SRConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/swin2sr/modeling_swin2sr.py#L1102"}}),qe=new Oe({props:{name:"forward",anchor:"transformers.Swin2SRForImageSuperResolution.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.FloatTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.Swin2SRForImageSuperResolution.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<a href="/docs/transformers/main/en/model_doc/poolformer#transformers.PoolFormerFeatureExtractor.__call__">Swin2SRImageProcessor.<strong>call</strong>()</a> for details.`,name:"pixel_values"},{anchor:"transformers.Swin2SRForImageSuperResolution.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.Swin2SRForImageSuperResolution.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.Swin2SRForImageSuperResolution.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.Swin2SRForImageSuperResolution.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/swin2sr/modeling_swin2sr.py#L1129",returnDescription:`
<p>A <code>transformers.modeling_outputs.ImageSuperResolutionOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/swin2sr#transformers.Swin2SRConfig"
>Swin2SRConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Reconstruction loss.</p>
</li>
<li>
<p><strong>reconstruction</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) \u2014 Reconstructed images, possibly upscaled.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each stage) of shape <code>(batch_size, sequence_length, hidden_size)</code>. Hidden-states
(also called feature maps) of the model at the output of each stage.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, patch_size, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.modeling_outputs.ImageSuperResolutionOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),re=new bs({props:{$$slots:{default:[ks]},$$scope:{ctx:P}}}),ae=new jn({props:{anchor:"transformers.Swin2SRForImageSuperResolution.forward.example",$$slots:{default:[Cs]},$$scope:{ctx:P}}}),{c(){m=n("meta"),S=p(),_=n("h1"),f=n("a"),w=n("span"),v(a.$$.fragment),g=p(),C=n("span"),et=i("Swin2SR"),To=p(),q=n("h2"),B=n("a"),no=n("span"),v(pe.$$.fragment),ot=p(),so=n("span"),tt=i("Overview"),xo=p(),j=n("p"),nt=i("The Swin2SR model was proposed in "),he=n("a"),st=i("Swin2SR: SwinV2 Transformer for Compressed Image Super-Resolution and Restoration"),rt=i(` by Marcos V. Conde, Ui-Jin Choi, Maxime Burchi, Radu Timofte.
Swin2R improves the `),ue=n("a"),at=i("SwinIR"),it=i(" model by incorporating "),Le=n("a"),lt=i("Swin Transformer v2"),ct=i(` layers which mitigates issues such as training instability, resolution gaps between pre-training
and fine-tuning, and hunger on data.`),Io=p(),Ue=n("p"),dt=i("The abstract from the paper is the following:"),Po=p(),We=n("p"),ro=n("em"),mt=i(`Compression plays an important role on the efficient transmission and storage of images and videos through band-limited systems such as streaming services, virtual reality or videogames. However, compression unavoidably leads to artifacts and the loss of the original information, which may severely degrade the visual quality. For these reasons, quality enhancement of compressed images has become a popular research topic. While most state-of-the-art image restoration methods are based on convolutional neural networks, other transformers-based methods such as SwinIR, show impressive performance on these tasks.
In this paper, we explore the novel Swin Transformer V2, to improve SwinIR for image super-resolution, and in particular, the compressed input scenario. Using this method we can tackle the major issues in training transformer vision models, such as training instability, resolution gaps between pre-training and fine-tuning, and hunger on data. We conduct experiments on three representative tasks: JPEG compression artifacts removal, image super-resolution (classical and lightweight), and compressed image super-resolution. Experimental results demonstrate that our method, Swin2SR, can improve the training convergence and performance of SwinIR, and is a top-5 solution at the \u201CAIM 2022 Challenge on Super-Resolution of Compressed Image and Video\u201D.`),jo=p(),J=n("img"),Eo=p(),fe=n("small"),pt=i("Swin2SR architecture. Taken from the "),Ve=n("a"),ht=i("original paper."),ko=p(),F=n("p"),ut=i("This model was contributed by "),ge=n("a"),ft=i("nielsr"),gt=i(`.
The original code can be found `),_e=n("a"),_t=i("here"),wt=i("."),Co=p(),z=n("h2"),G=n("a"),ao=n("span"),v(we.$$.fragment),St=p(),io=n("span"),vt=i("Resources"),Mo=p(),Y=n("p"),bt=i("Demo notebooks for Swin2SR can be found "),Se=n("a"),Rt=i("here"),$t=i("."),Ao=p(),X=n("p"),yt=i("A demo Space for image super-resolution with SwinSR can be found "),ve=n("a"),Tt=i("here"),xt=i("."),Fo=p(),N=n("h2"),K=n("a"),lo=n("span"),v(be.$$.fragment),It=p(),co=n("span"),Pt=i("Swin2SRImageProcessor"),qo=p(),M=n("div"),v(Re.$$.fragment),jt=p(),mo=n("p"),Et=i("Constructs a Swin2SR image processor."),kt=p(),Q=n("div"),v($e.$$.fragment),Ct=p(),po=n("p"),Mt=i("Preprocess an image or batch of images."),zo=p(),O=n("h2"),Z=n("a"),ho=n("span"),v(ye.$$.fragment),At=p(),uo=n("span"),Ft=i("Swin2SRConfig"),No=p(),x=n("div"),v(Te.$$.fragment),qt=p(),D=n("p"),zt=i("This is the configuration class to store the configuration of a "),He=n("a"),Nt=i("Swin2SRModel"),Ot=i(`. It is used to instantiate a Swin
Transformer v2 model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yield a similar configuration to that of the Swin Transformer v2
`),xe=n("a"),Dt=i("caidas/swin2sr-classicalsr-x2-64"),Lt=i(" architecture."),Ut=p(),L=n("p"),Wt=i("Configuration objects inherit from "),Be=n("a"),Vt=i("PretrainedConfig"),Ht=i(` and can be used to control the model outputs. Read the
documentation from `),Je=n("a"),Bt=i("PretrainedConfig"),Jt=i(" for more information."),Gt=p(),v(ee.$$.fragment),Oo=p(),U=n("h2"),oe=n("a"),fo=n("span"),v(Ie.$$.fragment),Yt=p(),go=n("span"),Xt=i("Swin2SRModel"),Do=p(),A=n("div"),v(Pe.$$.fragment),Kt=p(),je=n("p"),Qt=i(`The bare Swin2SR Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),Ee=n("a"),Zt=i("torch.nn.Module"),en=i(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),on=p(),E=n("div"),v(ke.$$.fragment),tn=p(),W=n("p"),nn=i("The "),Ge=n("a"),sn=i("Swin2SRModel"),rn=i(" forward method, overrides the "),_o=n("code"),an=i("__call__"),ln=i(" special method."),cn=p(),v(te.$$.fragment),dn=p(),v(ne.$$.fragment),Lo=p(),V=n("h2"),se=n("a"),wo=n("span"),v(Ce.$$.fragment),mn=p(),So=n("span"),pn=i("Swin2SRForImageSuperResolution"),Uo=p(),I=n("div"),v(Me.$$.fragment),hn=p(),vo=n("p"),un=i("Swin2SR Model transformer with an upsampler head on top for image super resolution and restoration."),fn=p(),Ae=n("p"),gn=i("This model is a PyTorch "),Fe=n("a"),_n=i("torch.nn.Module"),wn=i(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Sn=p(),k=n("div"),v(qe.$$.fragment),vn=p(),H=n("p"),bn=i("The "),Ye=n("a"),Rn=i("Swin2SRForImageSuperResolution"),$n=i(" forward method, overrides the "),bo=n("code"),yn=i("__call__"),Tn=i(" special method."),xn=p(),v(re.$$.fragment),In=p(),v(ae.$$.fragment),this.h()},l(e){const d=Ts('[data-svelte="svelte-1phssyn"]',document.head);m=s(d,"META",{name:!0,content:!0}),d.forEach(t),S=h(e),_=s(e,"H1",{class:!0});var ze=r(_);f=s(ze,"A",{id:!0,class:!0,href:!0});var Ro=r(f);w=s(Ro,"SPAN",{});var $o=r(w);b(a.$$.fragment,$o),$o.forEach(t),Ro.forEach(t),g=h(ze),C=s(ze,"SPAN",{});var yo=r(C);et=l(yo,"Swin2SR"),yo.forEach(t),ze.forEach(t),To=h(e),q=s(e,"H2",{class:!0});var Ne=r(q);B=s(Ne,"A",{id:!0,class:!0,href:!0});var Mn=r(B);no=s(Mn,"SPAN",{});var An=r(no);b(pe.$$.fragment,An),An.forEach(t),Mn.forEach(t),ot=h(Ne),so=s(Ne,"SPAN",{});var Fn=r(so);tt=l(Fn,"Overview"),Fn.forEach(t),Ne.forEach(t),xo=h(e),j=s(e,"P",{});var ie=r(j);nt=l(ie,"The Swin2SR model was proposed in "),he=s(ie,"A",{href:!0,rel:!0});var qn=r(he);st=l(qn,"Swin2SR: SwinV2 Transformer for Compressed Image Super-Resolution and Restoration"),qn.forEach(t),rt=l(ie,` by Marcos V. Conde, Ui-Jin Choi, Maxime Burchi, Radu Timofte.
Swin2R improves the `),ue=s(ie,"A",{href:!0,rel:!0});var zn=r(ue);at=l(zn,"SwinIR"),zn.forEach(t),it=l(ie," model by incorporating "),Le=s(ie,"A",{href:!0});var Nn=r(Le);lt=l(Nn,"Swin Transformer v2"),Nn.forEach(t),ct=l(ie,` layers which mitigates issues such as training instability, resolution gaps between pre-training
and fine-tuning, and hunger on data.`),ie.forEach(t),Io=h(e),Ue=s(e,"P",{});var On=r(Ue);dt=l(On,"The abstract from the paper is the following:"),On.forEach(t),Po=h(e),We=s(e,"P",{});var Dn=r(We);ro=s(Dn,"EM",{});var Ln=r(ro);mt=l(Ln,`Compression plays an important role on the efficient transmission and storage of images and videos through band-limited systems such as streaming services, virtual reality or videogames. However, compression unavoidably leads to artifacts and the loss of the original information, which may severely degrade the visual quality. For these reasons, quality enhancement of compressed images has become a popular research topic. While most state-of-the-art image restoration methods are based on convolutional neural networks, other transformers-based methods such as SwinIR, show impressive performance on these tasks.
In this paper, we explore the novel Swin Transformer V2, to improve SwinIR for image super-resolution, and in particular, the compressed input scenario. Using this method we can tackle the major issues in training transformer vision models, such as training instability, resolution gaps between pre-training and fine-tuning, and hunger on data. We conduct experiments on three representative tasks: JPEG compression artifacts removal, image super-resolution (classical and lightweight), and compressed image super-resolution. Experimental results demonstrate that our method, Swin2SR, can improve the training convergence and performance of SwinIR, and is a top-5 solution at the \u201CAIM 2022 Challenge on Super-Resolution of Compressed Image and Video\u201D.`),Ln.forEach(t),Dn.forEach(t),jo=h(e),J=s(e,"IMG",{src:!0,alt:!0,width:!0}),Eo=h(e),fe=s(e,"SMALL",{});var Pn=r(fe);pt=l(Pn,"Swin2SR architecture. Taken from the "),Ve=s(Pn,"A",{href:!0});var Un=r(Ve);ht=l(Un,"original paper."),Un.forEach(t),Pn.forEach(t),ko=h(e),F=s(e,"P",{});var Xe=r(F);ut=l(Xe,"This model was contributed by "),ge=s(Xe,"A",{href:!0,rel:!0});var Wn=r(ge);ft=l(Wn,"nielsr"),Wn.forEach(t),gt=l(Xe,`.
The original code can be found `),_e=s(Xe,"A",{href:!0,rel:!0});var Vn=r(_e);_t=l(Vn,"here"),Vn.forEach(t),wt=l(Xe,"."),Xe.forEach(t),Co=h(e),z=s(e,"H2",{class:!0});var Vo=r(z);G=s(Vo,"A",{id:!0,class:!0,href:!0});var Hn=r(G);ao=s(Hn,"SPAN",{});var Bn=r(ao);b(we.$$.fragment,Bn),Bn.forEach(t),Hn.forEach(t),St=h(Vo),io=s(Vo,"SPAN",{});var Jn=r(io);vt=l(Jn,"Resources"),Jn.forEach(t),Vo.forEach(t),Mo=h(e),Y=s(e,"P",{});var Ho=r(Y);bt=l(Ho,"Demo notebooks for Swin2SR can be found "),Se=s(Ho,"A",{href:!0,rel:!0});var Gn=r(Se);Rt=l(Gn,"here"),Gn.forEach(t),$t=l(Ho,"."),Ho.forEach(t),Ao=h(e),X=s(e,"P",{});var Bo=r(X);yt=l(Bo,"A demo Space for image super-resolution with SwinSR can be found "),ve=s(Bo,"A",{href:!0,rel:!0});var Yn=r(ve);Tt=l(Yn,"here"),Yn.forEach(t),xt=l(Bo,"."),Bo.forEach(t),Fo=h(e),N=s(e,"H2",{class:!0});var Jo=r(N);K=s(Jo,"A",{id:!0,class:!0,href:!0});var Xn=r(K);lo=s(Xn,"SPAN",{});var Kn=r(lo);b(be.$$.fragment,Kn),Kn.forEach(t),Xn.forEach(t),It=h(Jo),co=s(Jo,"SPAN",{});var Qn=r(co);Pt=l(Qn,"Swin2SRImageProcessor"),Qn.forEach(t),Jo.forEach(t),qo=h(e),M=s(e,"DIV",{class:!0});var Ke=r(M);b(Re.$$.fragment,Ke),jt=h(Ke),mo=s(Ke,"P",{});var Zn=r(mo);Et=l(Zn,"Constructs a Swin2SR image processor."),Zn.forEach(t),kt=h(Ke),Q=s(Ke,"DIV",{class:!0});var Go=r(Q);b($e.$$.fragment,Go),Ct=h(Go),po=s(Go,"P",{});var es=r(po);Mt=l(es,"Preprocess an image or batch of images."),es.forEach(t),Go.forEach(t),Ke.forEach(t),zo=h(e),O=s(e,"H2",{class:!0});var Yo=r(O);Z=s(Yo,"A",{id:!0,class:!0,href:!0});var os=r(Z);ho=s(os,"SPAN",{});var ts=r(ho);b(ye.$$.fragment,ts),ts.forEach(t),os.forEach(t),At=h(Yo),uo=s(Yo,"SPAN",{});var ns=r(uo);Ft=l(ns,"Swin2SRConfig"),ns.forEach(t),Yo.forEach(t),No=h(e),x=s(e,"DIV",{class:!0});var le=r(x);b(Te.$$.fragment,le),qt=h(le),D=s(le,"P",{});var Qe=r(D);zt=l(Qe,"This is the configuration class to store the configuration of a "),He=s(Qe,"A",{href:!0});var ss=r(He);Nt=l(ss,"Swin2SRModel"),ss.forEach(t),Ot=l(Qe,`. It is used to instantiate a Swin
Transformer v2 model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yield a similar configuration to that of the Swin Transformer v2
`),xe=s(Qe,"A",{href:!0,rel:!0});var rs=r(xe);Dt=l(rs,"caidas/swin2sr-classicalsr-x2-64"),rs.forEach(t),Lt=l(Qe," architecture."),Qe.forEach(t),Ut=h(le),L=s(le,"P",{});var Ze=r(L);Wt=l(Ze,"Configuration objects inherit from "),Be=s(Ze,"A",{href:!0});var as=r(Be);Vt=l(as,"PretrainedConfig"),as.forEach(t),Ht=l(Ze,` and can be used to control the model outputs. Read the
documentation from `),Je=s(Ze,"A",{href:!0});var is=r(Je);Bt=l(is,"PretrainedConfig"),is.forEach(t),Jt=l(Ze," for more information."),Ze.forEach(t),Gt=h(le),b(ee.$$.fragment,le),le.forEach(t),Oo=h(e),U=s(e,"H2",{class:!0});var Xo=r(U);oe=s(Xo,"A",{id:!0,class:!0,href:!0});var ls=r(oe);fo=s(ls,"SPAN",{});var cs=r(fo);b(Ie.$$.fragment,cs),cs.forEach(t),ls.forEach(t),Yt=h(Xo),go=s(Xo,"SPAN",{});var ds=r(go);Xt=l(ds,"Swin2SRModel"),ds.forEach(t),Xo.forEach(t),Do=h(e),A=s(e,"DIV",{class:!0});var eo=r(A);b(Pe.$$.fragment,eo),Kt=h(eo),je=s(eo,"P",{});var Ko=r(je);Qt=l(Ko,`The bare Swin2SR Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),Ee=s(Ko,"A",{href:!0,rel:!0});var ms=r(Ee);Zt=l(ms,"torch.nn.Module"),ms.forEach(t),en=l(Ko,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Ko.forEach(t),on=h(eo),E=s(eo,"DIV",{class:!0});var ce=r(E);b(ke.$$.fragment,ce),tn=h(ce),W=s(ce,"P",{});var oo=r(W);nn=l(oo,"The "),Ge=s(oo,"A",{href:!0});var ps=r(Ge);sn=l(ps,"Swin2SRModel"),ps.forEach(t),rn=l(oo," forward method, overrides the "),_o=s(oo,"CODE",{});var hs=r(_o);an=l(hs,"__call__"),hs.forEach(t),ln=l(oo," special method."),oo.forEach(t),cn=h(ce),b(te.$$.fragment,ce),dn=h(ce),b(ne.$$.fragment,ce),ce.forEach(t),eo.forEach(t),Lo=h(e),V=s(e,"H2",{class:!0});var Qo=r(V);se=s(Qo,"A",{id:!0,class:!0,href:!0});var us=r(se);wo=s(us,"SPAN",{});var fs=r(wo);b(Ce.$$.fragment,fs),fs.forEach(t),us.forEach(t),mn=h(Qo),So=s(Qo,"SPAN",{});var gs=r(So);pn=l(gs,"Swin2SRForImageSuperResolution"),gs.forEach(t),Qo.forEach(t),Uo=h(e),I=s(e,"DIV",{class:!0});var de=r(I);b(Me.$$.fragment,de),hn=h(de),vo=s(de,"P",{});var _s=r(vo);un=l(_s,"Swin2SR Model transformer with an upsampler head on top for image super resolution and restoration."),_s.forEach(t),fn=h(de),Ae=s(de,"P",{});var Zo=r(Ae);gn=l(Zo,"This model is a PyTorch "),Fe=s(Zo,"A",{href:!0,rel:!0});var ws=r(Fe);_n=l(ws,"torch.nn.Module"),ws.forEach(t),wn=l(Zo,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Zo.forEach(t),Sn=h(de),k=s(de,"DIV",{class:!0});var me=r(k);b(qe.$$.fragment,me),vn=h(me),H=s(me,"P",{});var to=r(H);bn=l(to,"The "),Ye=s(to,"A",{href:!0});var Ss=r(Ye);Rn=l(Ss,"Swin2SRForImageSuperResolution"),Ss.forEach(t),$n=l(to," forward method, overrides the "),bo=s(to,"CODE",{});var vs=r(bo);yn=l(vs,"__call__"),vs.forEach(t),Tn=l(to," special method."),to.forEach(t),xn=h(me),b(re.$$.fragment,me),In=h(me),b(ae.$$.fragment,me),me.forEach(t),de.forEach(t),this.h()},h(){c(m,"name","hf:doc:metadata"),c(m,"content",JSON.stringify(As)),c(f,"id","swin2sr"),c(f,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(f,"href","#swin2sr"),c(_,"class","relative group"),c(B,"id","overview"),c(B,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(B,"href","#overview"),c(q,"class","relative group"),c(he,"href","https://arxiv.org/abs/2209.11345"),c(he,"rel","nofollow"),c(ue,"href","https://github.com/JingyunLiang/SwinIR/"),c(ue,"rel","nofollow"),c(Le,"href","swinv2"),xs(J.src,Cn="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/swin2sr_architecture.png")||c(J,"src",Cn),c(J,"alt","drawing"),c(J,"width","600"),c(Ve,"href","https://arxiv.org/abs/2209.11345"),c(ge,"href","https://huggingface.co/nielsr"),c(ge,"rel","nofollow"),c(_e,"href","https://github.com/mv-lab/swin2sr"),c(_e,"rel","nofollow"),c(G,"id","resources"),c(G,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(G,"href","#resources"),c(z,"class","relative group"),c(Se,"href","https://github.com/NielsRogge/Transformers-Tutorials/tree/master/Swin2SR"),c(Se,"rel","nofollow"),c(ve,"href","https://huggingface.co/spaces/jjourney1125/swin2sr"),c(ve,"rel","nofollow"),c(K,"id","transformers.Swin2SRImageProcessor"),c(K,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(K,"href","#transformers.Swin2SRImageProcessor"),c(N,"class","relative group"),c(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Z,"id","transformers.Swin2SRConfig"),c(Z,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Z,"href","#transformers.Swin2SRConfig"),c(O,"class","relative group"),c(He,"href","/docs/transformers/main/en/model_doc/swin2sr#transformers.Swin2SRModel"),c(xe,"href","https://huggingface.co/caidas/swin2sr-classicalsr-x2-64"),c(xe,"rel","nofollow"),c(Be,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),c(Je,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),c(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(oe,"id","transformers.Swin2SRModel"),c(oe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(oe,"href","#transformers.Swin2SRModel"),c(U,"class","relative group"),c(Ee,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(Ee,"rel","nofollow"),c(Ge,"href","/docs/transformers/main/en/model_doc/swin2sr#transformers.Swin2SRModel"),c(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(se,"id","transformers.Swin2SRForImageSuperResolution"),c(se,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(se,"href","#transformers.Swin2SRForImageSuperResolution"),c(V,"class","relative group"),c(Fe,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(Fe,"rel","nofollow"),c(Ye,"href","/docs/transformers/main/en/model_doc/swin2sr#transformers.Swin2SRForImageSuperResolution"),c(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,d){o(document.head,m),u(e,S,d),u(e,_,d),o(_,f),o(f,w),R(a,w,null),o(_,g),o(_,C),o(C,et),u(e,To,d),u(e,q,d),o(q,B),o(B,no),R(pe,no,null),o(q,ot),o(q,so),o(so,tt),u(e,xo,d),u(e,j,d),o(j,nt),o(j,he),o(he,st),o(j,rt),o(j,ue),o(ue,at),o(j,it),o(j,Le),o(Le,lt),o(j,ct),u(e,Io,d),u(e,Ue,d),o(Ue,dt),u(e,Po,d),u(e,We,d),o(We,ro),o(ro,mt),u(e,jo,d),u(e,J,d),u(e,Eo,d),u(e,fe,d),o(fe,pt),o(fe,Ve),o(Ve,ht),u(e,ko,d),u(e,F,d),o(F,ut),o(F,ge),o(ge,ft),o(F,gt),o(F,_e),o(_e,_t),o(F,wt),u(e,Co,d),u(e,z,d),o(z,G),o(G,ao),R(we,ao,null),o(z,St),o(z,io),o(io,vt),u(e,Mo,d),u(e,Y,d),o(Y,bt),o(Y,Se),o(Se,Rt),o(Y,$t),u(e,Ao,d),u(e,X,d),o(X,yt),o(X,ve),o(ve,Tt),o(X,xt),u(e,Fo,d),u(e,N,d),o(N,K),o(K,lo),R(be,lo,null),o(N,It),o(N,co),o(co,Pt),u(e,qo,d),u(e,M,d),R(Re,M,null),o(M,jt),o(M,mo),o(mo,Et),o(M,kt),o(M,Q),R($e,Q,null),o(Q,Ct),o(Q,po),o(po,Mt),u(e,zo,d),u(e,O,d),o(O,Z),o(Z,ho),R(ye,ho,null),o(O,At),o(O,uo),o(uo,Ft),u(e,No,d),u(e,x,d),R(Te,x,null),o(x,qt),o(x,D),o(D,zt),o(D,He),o(He,Nt),o(D,Ot),o(D,xe),o(xe,Dt),o(D,Lt),o(x,Ut),o(x,L),o(L,Wt),o(L,Be),o(Be,Vt),o(L,Ht),o(L,Je),o(Je,Bt),o(L,Jt),o(x,Gt),R(ee,x,null),u(e,Oo,d),u(e,U,d),o(U,oe),o(oe,fo),R(Ie,fo,null),o(U,Yt),o(U,go),o(go,Xt),u(e,Do,d),u(e,A,d),R(Pe,A,null),o(A,Kt),o(A,je),o(je,Qt),o(je,Ee),o(Ee,Zt),o(je,en),o(A,on),o(A,E),R(ke,E,null),o(E,tn),o(E,W),o(W,nn),o(W,Ge),o(Ge,sn),o(W,rn),o(W,_o),o(_o,an),o(W,ln),o(E,cn),R(te,E,null),o(E,dn),R(ne,E,null),u(e,Lo,d),u(e,V,d),o(V,se),o(se,wo),R(Ce,wo,null),o(V,mn),o(V,So),o(So,pn),u(e,Uo,d),u(e,I,d),R(Me,I,null),o(I,hn),o(I,vo),o(vo,un),o(I,fn),o(I,Ae),o(Ae,gn),o(Ae,Fe),o(Fe,_n),o(Ae,wn),o(I,Sn),o(I,k),R(qe,k,null),o(k,vn),o(k,H),o(H,bn),o(H,Ye),o(Ye,Rn),o(H,$n),o(H,bo),o(bo,yn),o(H,Tn),o(k,xn),R(re,k,null),o(k,In),R(ae,k,null),Wo=!0},p(e,[d]){const ze={};d&2&&(ze.$$scope={dirty:d,ctx:e}),ee.$set(ze);const Ro={};d&2&&(Ro.$$scope={dirty:d,ctx:e}),te.$set(Ro);const $o={};d&2&&($o.$$scope={dirty:d,ctx:e}),ne.$set($o);const yo={};d&2&&(yo.$$scope={dirty:d,ctx:e}),re.$set(yo);const Ne={};d&2&&(Ne.$$scope={dirty:d,ctx:e}),ae.$set(Ne)},i(e){Wo||($(a.$$.fragment,e),$(pe.$$.fragment,e),$(we.$$.fragment,e),$(be.$$.fragment,e),$(Re.$$.fragment,e),$($e.$$.fragment,e),$(ye.$$.fragment,e),$(Te.$$.fragment,e),$(ee.$$.fragment,e),$(Ie.$$.fragment,e),$(Pe.$$.fragment,e),$(ke.$$.fragment,e),$(te.$$.fragment,e),$(ne.$$.fragment,e),$(Ce.$$.fragment,e),$(Me.$$.fragment,e),$(qe.$$.fragment,e),$(re.$$.fragment,e),$(ae.$$.fragment,e),Wo=!0)},o(e){y(a.$$.fragment,e),y(pe.$$.fragment,e),y(we.$$.fragment,e),y(be.$$.fragment,e),y(Re.$$.fragment,e),y($e.$$.fragment,e),y(ye.$$.fragment,e),y(Te.$$.fragment,e),y(ee.$$.fragment,e),y(Ie.$$.fragment,e),y(Pe.$$.fragment,e),y(ke.$$.fragment,e),y(te.$$.fragment,e),y(ne.$$.fragment,e),y(Ce.$$.fragment,e),y(Me.$$.fragment,e),y(qe.$$.fragment,e),y(re.$$.fragment,e),y(ae.$$.fragment,e),Wo=!1},d(e){t(m),e&&t(S),e&&t(_),T(a),e&&t(To),e&&t(q),T(pe),e&&t(xo),e&&t(j),e&&t(Io),e&&t(Ue),e&&t(Po),e&&t(We),e&&t(jo),e&&t(J),e&&t(Eo),e&&t(fe),e&&t(ko),e&&t(F),e&&t(Co),e&&t(z),T(we),e&&t(Mo),e&&t(Y),e&&t(Ao),e&&t(X),e&&t(Fo),e&&t(N),T(be),e&&t(qo),e&&t(M),T(Re),T($e),e&&t(zo),e&&t(O),T(ye),e&&t(No),e&&t(x),T(Te),T(ee),e&&t(Oo),e&&t(U),T(Ie),e&&t(Do),e&&t(A),T(Pe),T(ke),T(te),T(ne),e&&t(Lo),e&&t(V),T(Ce),e&&t(Uo),e&&t(I),T(Me),T(qe),T(re),T(ae)}}}const As={local:"swin2sr",sections:[{local:"overview",title:"Overview"},{local:"resources",title:"Resources"},{local:"transformers.Swin2SRImageProcessor",title:"Swin2SRImageProcessor"},{local:"transformers.Swin2SRConfig",title:"Swin2SRConfig"},{local:"transformers.Swin2SRModel",title:"Swin2SRModel"},{local:"transformers.Swin2SRForImageSuperResolution",title:"Swin2SRForImageSuperResolution"}],title:"Swin2SR"};function Fs(P){return Is(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Us extends Rs{constructor(m){super();$s(this,m,Fs,Ms,ys,{})}}export{Us as default,As as metadata};
