import{S as Rn,i as $n,s as yn,e as s,k as m,w as v,t as i,M as Tn,c as n,d as t,m as h,a as r,x as b,h as l,b as c,N as xn,G as o,g as u,y as R,q as $,o as y,B as T,v as In,L as Es}from"../../chunks/vendor-hf-doc-builder.js";import{T as bn}from"../../chunks/Tip-hf-doc-builder.js";import{D as Oe}from"../../chunks/Docstring-hf-doc-builder.js";import{C as js}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as De}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Ps}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Pn(P){let p,S,_,f,w;return f=new js({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(){p=s("p"),S=i("Example:"),_=m(),v(f.$$.fragment)},l(a){p=n(a,"P",{});var g=r(p);S=l(g,"Example:"),g.forEach(t),_=h(a),b(f.$$.fragment,a)},m(a,g){u(a,p,g),o(p,S),u(a,_,g),R(f,a,g),w=!0},p:Es,i(a){w||($(f.$$.fragment,a),w=!0)},o(a){y(f.$$.fragment,a),w=!1},d(a){a&&t(p),a&&t(_),T(f,a)}}}function En(P){let p,S,_,f,w;return{c(){p=s("p"),S=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=s("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){p=n(a,"P",{});var g=r(p);S=l(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=n(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,p,g),o(p,S),o(p,_),o(_,f),o(p,w)},d(a){a&&t(p)}}}function jn(P){let p,S,_,f,w;return f=new js({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(){p=s("p"),S=i("Example:"),_=m(),v(f.$$.fragment)},l(a){p=n(a,"P",{});var g=r(p);S=l(g,"Example:"),g.forEach(t),_=h(a),b(f.$$.fragment,a)},m(a,g){u(a,p,g),o(p,S),u(a,_,g),R(f,a,g),w=!0},p:Es,i(a){w||($(f.$$.fragment,a),w=!0)},o(a){y(f.$$.fragment,a),w=!1},d(a){a&&t(p),a&&t(_),T(f,a)}}}function kn(P){let p,S,_,f,w;return{c(){p=s("p"),S=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=s("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){p=n(a,"P",{});var g=r(p);S=l(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=n(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,p,g),o(p,S),o(p,_),o(_,f),o(p,w)},d(a){a&&t(p)}}}function Cn(P){let p,S,_,f,w;return f=new js({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(){p=s("p"),S=i("Example:"),_=m(),v(f.$$.fragment)},l(a){p=n(a,"P",{});var g=r(p);S=l(g,"Example:"),g.forEach(t),_=h(a),b(f.$$.fragment,a)},m(a,g){u(a,p,g),o(p,S),u(a,_,g),R(f,a,g),w=!0},p:Es,i(a){w||($(f.$$.fragment,a),w=!0)},o(a){y(f.$$.fragment,a),w=!1},d(a){a&&t(p),a&&t(_),T(f,a)}}}function Mn(P){let p,S,_,f,w,a,g,C,et,To,F,B,so,me,ot,no,tt,xo,E,st,he,nt,rt,ue,at,it,Le,lt,ct,Io,Ue,dt,Po,Ve,ro,pt,Eo,J,ks,jo,fe,mt,We,ht,ko,q,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,qo,N,K,lo,be,It,co,Pt,Fo,M,Re,Et,po,jt,kt,Q,$e,Ct,mo,Mt,zo,O,Z,ho,ye,At,uo,qt,No,x,Te,Ft,D,zt,He,Nt,Ot,xe,Dt,Lt,Ut,L,Vt,Be,Wt,Ht,Je,Bt,Jt,Gt,ee,Oo,U,oe,fo,Ie,Yt,go,Xt,Do,A,Pe,Kt,Ee,Qt,je,Zt,es,os,j,ke,ts,V,ss,Ge,ns,rs,_o,as,is,ls,te,cs,se,Lo,W,ne,wo,Ce,ds,So,ps,Uo,I,Me,ms,vo,hs,us,Ae,fs,qe,gs,_s,ws,k,Fe,Ss,H,vs,Ye,bs,Rs,bo,$s,ys,Ts,re,xs,ae,Vo;return a=new De({}),me=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/v4.27.1/src/transformers/models/swin2sr/image_processing_swin2sr.py#L30"}}),$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[str, transformers.utils.generic.TensorType, 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/v4.27.1/src/transformers/models/swin2sr/image_processing_swin2sr.py#L106"}}),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:"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.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/v4.27.1/src/transformers/models/swin2sr/configuration_swin2sr.py#L30"}}),ee=new Ps({props:{anchor:"transformers.Swin2SRConfig.example",$$slots:{default:[Pn]},$$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/v4.27.1/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/v4.27.1/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/v4.27.1/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/v4.27.1/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<a href="/docs/transformers/v4.27.1/en/model_doc/videomae#transformers.VideoMAEFeatureExtractor.__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/v4.27.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/swin2sr/modeling_swin2sr.py#L897",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.27.1/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/v4.27.1/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/v4.27.1/en/main_classes/output#transformers.modeling_outputs.BaseModelOutput"
>transformers.modeling_outputs.BaseModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),te=new bn({props:{$$slots:{default:[En]},$$scope:{ctx:P}}}),se=new Ps({props:{anchor:"transformers.Swin2SRModel.forward.example",$$slots:{default:[jn]},$$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/v4.27.1/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/v4.27.1/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/v4.27.1/src/transformers/models/swin2sr/modeling_swin2sr.py#L1102"}}),Fe=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/v4.27.1/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<a href="/docs/transformers/v4.27.1/en/model_doc/videomae#transformers.VideoMAEFeatureExtractor.__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/v4.27.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/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/v4.27.1/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 bn({props:{$$slots:{default:[kn]},$$scope:{ctx:P}}}),ae=new Ps({props:{anchor:"transformers.Swin2SRForImageSuperResolution.forward.example",$$slots:{default:[Cn]},$$scope:{ctx:P}}}),{c(){p=s("meta"),S=m(),_=s("h1"),f=s("a"),w=s("span"),v(a.$$.fragment),g=m(),C=s("span"),et=i("Swin2SR"),To=m(),F=s("h2"),B=s("a"),so=s("span"),v(me.$$.fragment),ot=m(),no=s("span"),tt=i("Overview"),xo=m(),E=s("p"),st=i("The Swin2SR model was proposed in "),he=s("a"),nt=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=s("a"),at=i("SwinIR"),it=i(" model by incorporating "),Le=s("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=m(),Ue=s("p"),dt=i("The abstract from the paper is the following:"),Po=m(),Ve=s("p"),ro=s("em"),pt=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.`),Eo=m(),J=s("img"),jo=m(),fe=s("small"),mt=i("Swin2SR architecture. Taken from the "),We=s("a"),ht=i("original paper."),ko=m(),q=s("p"),ut=i("This model was contributed by "),ge=s("a"),ft=i("nielsr"),gt=i(`.
The original code can be found `),_e=s("a"),_t=i("here"),wt=i("."),Co=m(),z=s("h2"),G=s("a"),ao=s("span"),v(we.$$.fragment),St=m(),io=s("span"),vt=i("Resources"),Mo=m(),Y=s("p"),bt=i("Demo notebooks for Swin2SR can be found "),Se=s("a"),Rt=i("here"),$t=i("."),Ao=m(),X=s("p"),yt=i("A demo Space for image super-resolution with SwinSR can be found "),ve=s("a"),Tt=i("here"),xt=i("."),qo=m(),N=s("h2"),K=s("a"),lo=s("span"),v(be.$$.fragment),It=m(),co=s("span"),Pt=i("Swin2SRImageProcessor"),Fo=m(),M=s("div"),v(Re.$$.fragment),Et=m(),po=s("p"),jt=i("Constructs a Swin2SR image processor."),kt=m(),Q=s("div"),v($e.$$.fragment),Ct=m(),mo=s("p"),Mt=i("Preprocess an image or batch of images."),zo=m(),O=s("h2"),Z=s("a"),ho=s("span"),v(ye.$$.fragment),At=m(),uo=s("span"),qt=i("Swin2SRConfig"),No=m(),x=s("div"),v(Te.$$.fragment),Ft=m(),D=s("p"),zt=i("This is the configuration class to store the configuration of a "),He=s("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=s("a"),Dt=i("caidas/swin2sr-classicalsr-x2-64"),Lt=i(" architecture."),Ut=m(),L=s("p"),Vt=i("Configuration objects inherit from "),Be=s("a"),Wt=i("PretrainedConfig"),Ht=i(` and can be used to control the model outputs. Read the
documentation from `),Je=s("a"),Bt=i("PretrainedConfig"),Jt=i(" for more information."),Gt=m(),v(ee.$$.fragment),Oo=m(),U=s("h2"),oe=s("a"),fo=s("span"),v(Ie.$$.fragment),Yt=m(),go=s("span"),Xt=i("Swin2SRModel"),Do=m(),A=s("div"),v(Pe.$$.fragment),Kt=m(),Ee=s("p"),Qt=i(`The bare Swin2SR Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),je=s("a"),Zt=i("torch.nn.Module"),es=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.`),os=m(),j=s("div"),v(ke.$$.fragment),ts=m(),V=s("p"),ss=i("The "),Ge=s("a"),ns=i("Swin2SRModel"),rs=i(" forward method, overrides the "),_o=s("code"),as=i("__call__"),is=i(" special method."),ls=m(),v(te.$$.fragment),cs=m(),v(se.$$.fragment),Lo=m(),W=s("h2"),ne=s("a"),wo=s("span"),v(Ce.$$.fragment),ds=m(),So=s("span"),ps=i("Swin2SRForImageSuperResolution"),Uo=m(),I=s("div"),v(Me.$$.fragment),ms=m(),vo=s("p"),hs=i("Swin2SR Model transformer with an upsampler head on top for image super resolution and restoration."),us=m(),Ae=s("p"),fs=i("This model is a PyTorch "),qe=s("a"),gs=i("torch.nn.Module"),_s=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.`),ws=m(),k=s("div"),v(Fe.$$.fragment),Ss=m(),H=s("p"),vs=i("The "),Ye=s("a"),bs=i("Swin2SRForImageSuperResolution"),Rs=i(" forward method, overrides the "),bo=s("code"),$s=i("__call__"),ys=i(" special method."),Ts=m(),v(re.$$.fragment),xs=m(),v(ae.$$.fragment),this.h()},l(e){const d=Tn('[data-svelte="svelte-1phssyn"]',document.head);p=n(d,"META",{name:!0,content:!0}),d.forEach(t),S=h(e),_=n(e,"H1",{class:!0});var ze=r(_);f=n(ze,"A",{id:!0,class:!0,href:!0});var Ro=r(f);w=n(Ro,"SPAN",{});var $o=r(w);b(a.$$.fragment,$o),$o.forEach(t),Ro.forEach(t),g=h(ze),C=n(ze,"SPAN",{});var yo=r(C);et=l(yo,"Swin2SR"),yo.forEach(t),ze.forEach(t),To=h(e),F=n(e,"H2",{class:!0});var Ne=r(F);B=n(Ne,"A",{id:!0,class:!0,href:!0});var Cs=r(B);so=n(Cs,"SPAN",{});var Ms=r(so);b(me.$$.fragment,Ms),Ms.forEach(t),Cs.forEach(t),ot=h(Ne),no=n(Ne,"SPAN",{});var As=r(no);tt=l(As,"Overview"),As.forEach(t),Ne.forEach(t),xo=h(e),E=n(e,"P",{});var ie=r(E);st=l(ie,"The Swin2SR model was proposed in "),he=n(ie,"A",{href:!0,rel:!0});var qs=r(he);nt=l(qs,"Swin2SR: SwinV2 Transformer for Compressed Image Super-Resolution and Restoration"),qs.forEach(t),rt=l(ie,` by Marcos V. Conde, Ui-Jin Choi, Maxime Burchi, Radu Timofte.
Swin2R improves the `),ue=n(ie,"A",{href:!0,rel:!0});var Fs=r(ue);at=l(Fs,"SwinIR"),Fs.forEach(t),it=l(ie," model by incorporating "),Le=n(ie,"A",{href:!0});var zs=r(Le);lt=l(zs,"Swin Transformer v2"),zs.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=n(e,"P",{});var Ns=r(Ue);dt=l(Ns,"The abstract from the paper is the following:"),Ns.forEach(t),Po=h(e),Ve=n(e,"P",{});var Os=r(Ve);ro=n(Os,"EM",{});var Ds=r(ro);pt=l(Ds,`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.`),Ds.forEach(t),Os.forEach(t),Eo=h(e),J=n(e,"IMG",{src:!0,alt:!0,width:!0}),jo=h(e),fe=n(e,"SMALL",{});var Is=r(fe);mt=l(Is,"Swin2SR architecture. Taken from the "),We=n(Is,"A",{href:!0});var Ls=r(We);ht=l(Ls,"original paper."),Ls.forEach(t),Is.forEach(t),ko=h(e),q=n(e,"P",{});var Xe=r(q);ut=l(Xe,"This model was contributed by "),ge=n(Xe,"A",{href:!0,rel:!0});var Us=r(ge);ft=l(Us,"nielsr"),Us.forEach(t),gt=l(Xe,`.
The original code can be found `),_e=n(Xe,"A",{href:!0,rel:!0});var Vs=r(_e);_t=l(Vs,"here"),Vs.forEach(t),wt=l(Xe,"."),Xe.forEach(t),Co=h(e),z=n(e,"H2",{class:!0});var Wo=r(z);G=n(Wo,"A",{id:!0,class:!0,href:!0});var Ws=r(G);ao=n(Ws,"SPAN",{});var Hs=r(ao);b(we.$$.fragment,Hs),Hs.forEach(t),Ws.forEach(t),St=h(Wo),io=n(Wo,"SPAN",{});var Bs=r(io);vt=l(Bs,"Resources"),Bs.forEach(t),Wo.forEach(t),Mo=h(e),Y=n(e,"P",{});var Ho=r(Y);bt=l(Ho,"Demo notebooks for Swin2SR can be found "),Se=n(Ho,"A",{href:!0,rel:!0});var Js=r(Se);Rt=l(Js,"here"),Js.forEach(t),$t=l(Ho,"."),Ho.forEach(t),Ao=h(e),X=n(e,"P",{});var Bo=r(X);yt=l(Bo,"A demo Space for image super-resolution with SwinSR can be found "),ve=n(Bo,"A",{href:!0,rel:!0});var Gs=r(ve);Tt=l(Gs,"here"),Gs.forEach(t),xt=l(Bo,"."),Bo.forEach(t),qo=h(e),N=n(e,"H2",{class:!0});var Jo=r(N);K=n(Jo,"A",{id:!0,class:!0,href:!0});var Ys=r(K);lo=n(Ys,"SPAN",{});var Xs=r(lo);b(be.$$.fragment,Xs),Xs.forEach(t),Ys.forEach(t),It=h(Jo),co=n(Jo,"SPAN",{});var Ks=r(co);Pt=l(Ks,"Swin2SRImageProcessor"),Ks.forEach(t),Jo.forEach(t),Fo=h(e),M=n(e,"DIV",{class:!0});var Ke=r(M);b(Re.$$.fragment,Ke),Et=h(Ke),po=n(Ke,"P",{});var Qs=r(po);jt=l(Qs,"Constructs a Swin2SR image processor."),Qs.forEach(t),kt=h(Ke),Q=n(Ke,"DIV",{class:!0});var Go=r(Q);b($e.$$.fragment,Go),Ct=h(Go),mo=n(Go,"P",{});var Zs=r(mo);Mt=l(Zs,"Preprocess an image or batch of images."),Zs.forEach(t),Go.forEach(t),Ke.forEach(t),zo=h(e),O=n(e,"H2",{class:!0});var Yo=r(O);Z=n(Yo,"A",{id:!0,class:!0,href:!0});var en=r(Z);ho=n(en,"SPAN",{});var on=r(ho);b(ye.$$.fragment,on),on.forEach(t),en.forEach(t),At=h(Yo),uo=n(Yo,"SPAN",{});var tn=r(uo);qt=l(tn,"Swin2SRConfig"),tn.forEach(t),Yo.forEach(t),No=h(e),x=n(e,"DIV",{class:!0});var le=r(x);b(Te.$$.fragment,le),Ft=h(le),D=n(le,"P",{});var Qe=r(D);zt=l(Qe,"This is the configuration class to store the configuration of a "),He=n(Qe,"A",{href:!0});var sn=r(He);Nt=l(sn,"Swin2SRModel"),sn.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=n(Qe,"A",{href:!0,rel:!0});var nn=r(xe);Dt=l(nn,"caidas/swin2sr-classicalsr-x2-64"),nn.forEach(t),Lt=l(Qe," architecture."),Qe.forEach(t),Ut=h(le),L=n(le,"P",{});var Ze=r(L);Vt=l(Ze,"Configuration objects inherit from "),Be=n(Ze,"A",{href:!0});var rn=r(Be);Wt=l(rn,"PretrainedConfig"),rn.forEach(t),Ht=l(Ze,` and can be used to control the model outputs. Read the
documentation from `),Je=n(Ze,"A",{href:!0});var an=r(Je);Bt=l(an,"PretrainedConfig"),an.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=n(e,"H2",{class:!0});var Xo=r(U);oe=n(Xo,"A",{id:!0,class:!0,href:!0});var ln=r(oe);fo=n(ln,"SPAN",{});var cn=r(fo);b(Ie.$$.fragment,cn),cn.forEach(t),ln.forEach(t),Yt=h(Xo),go=n(Xo,"SPAN",{});var dn=r(go);Xt=l(dn,"Swin2SRModel"),dn.forEach(t),Xo.forEach(t),Do=h(e),A=n(e,"DIV",{class:!0});var eo=r(A);b(Pe.$$.fragment,eo),Kt=h(eo),Ee=n(eo,"P",{});var Ko=r(Ee);Qt=l(Ko,`The bare Swin2SR Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),je=n(Ko,"A",{href:!0,rel:!0});var pn=r(je);Zt=l(pn,"torch.nn.Module"),pn.forEach(t),es=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),os=h(eo),j=n(eo,"DIV",{class:!0});var ce=r(j);b(ke.$$.fragment,ce),ts=h(ce),V=n(ce,"P",{});var oo=r(V);ss=l(oo,"The "),Ge=n(oo,"A",{href:!0});var mn=r(Ge);ns=l(mn,"Swin2SRModel"),mn.forEach(t),rs=l(oo," forward method, overrides the "),_o=n(oo,"CODE",{});var hn=r(_o);as=l(hn,"__call__"),hn.forEach(t),is=l(oo," special method."),oo.forEach(t),ls=h(ce),b(te.$$.fragment,ce),cs=h(ce),b(se.$$.fragment,ce),ce.forEach(t),eo.forEach(t),Lo=h(e),W=n(e,"H2",{class:!0});var Qo=r(W);ne=n(Qo,"A",{id:!0,class:!0,href:!0});var un=r(ne);wo=n(un,"SPAN",{});var fn=r(wo);b(Ce.$$.fragment,fn),fn.forEach(t),un.forEach(t),ds=h(Qo),So=n(Qo,"SPAN",{});var gn=r(So);ps=l(gn,"Swin2SRForImageSuperResolution"),gn.forEach(t),Qo.forEach(t),Uo=h(e),I=n(e,"DIV",{class:!0});var de=r(I);b(Me.$$.fragment,de),ms=h(de),vo=n(de,"P",{});var _n=r(vo);hs=l(_n,"Swin2SR Model transformer with an upsampler head on top for image super resolution and restoration."),_n.forEach(t),us=h(de),Ae=n(de,"P",{});var Zo=r(Ae);fs=l(Zo,"This model is a PyTorch "),qe=n(Zo,"A",{href:!0,rel:!0});var wn=r(qe);gs=l(wn,"torch.nn.Module"),wn.forEach(t),_s=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),ws=h(de),k=n(de,"DIV",{class:!0});var pe=r(k);b(Fe.$$.fragment,pe),Ss=h(pe),H=n(pe,"P",{});var to=r(H);vs=l(to,"The "),Ye=n(to,"A",{href:!0});var Sn=r(Ye);bs=l(Sn,"Swin2SRForImageSuperResolution"),Sn.forEach(t),Rs=l(to," forward method, overrides the "),bo=n(to,"CODE",{});var vn=r(bo);$s=l(vn,"__call__"),vn.forEach(t),ys=l(to," special method."),to.forEach(t),Ts=h(pe),b(re.$$.fragment,pe),xs=h(pe),b(ae.$$.fragment,pe),pe.forEach(t),de.forEach(t),this.h()},h(){c(p,"name","hf:doc:metadata"),c(p,"content",JSON.stringify(An)),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(F,"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"),xn(J.src,ks="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/swin2sr_architecture.png")||c(J,"src",ks),c(J,"alt","drawing"),c(J,"width","600"),c(We,"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/v4.27.1/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/v4.27.1/en/main_classes/configuration#transformers.PretrainedConfig"),c(Je,"href","/docs/transformers/v4.27.1/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(je,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(je,"rel","nofollow"),c(Ge,"href","/docs/transformers/v4.27.1/en/model_doc/swin2sr#transformers.Swin2SRModel"),c(j,"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(ne,"id","transformers.Swin2SRForImageSuperResolution"),c(ne,"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(ne,"href","#transformers.Swin2SRForImageSuperResolution"),c(W,"class","relative group"),c(qe,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(qe,"rel","nofollow"),c(Ye,"href","/docs/transformers/v4.27.1/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,p),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,F,d),o(F,B),o(B,so),R(me,so,null),o(F,ot),o(F,no),o(no,tt),u(e,xo,d),u(e,E,d),o(E,st),o(E,he),o(he,nt),o(E,rt),o(E,ue),o(ue,at),o(E,it),o(E,Le),o(Le,lt),o(E,ct),u(e,Io,d),u(e,Ue,d),o(Ue,dt),u(e,Po,d),u(e,Ve,d),o(Ve,ro),o(ro,pt),u(e,Eo,d),u(e,J,d),u(e,jo,d),u(e,fe,d),o(fe,mt),o(fe,We),o(We,ht),u(e,ko,d),u(e,q,d),o(q,ut),o(q,ge),o(ge,ft),o(q,gt),o(q,_e),o(_e,_t),o(q,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,qo,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,Fo,d),u(e,M,d),R(Re,M,null),o(M,Et),o(M,po),o(po,jt),o(M,kt),o(M,Q),R($e,Q,null),o(Q,Ct),o(Q,mo),o(mo,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,qt),u(e,No,d),u(e,x,d),R(Te,x,null),o(x,Ft),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,Vt),o(L,Be),o(Be,Wt),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,Ee),o(Ee,Qt),o(Ee,je),o(je,Zt),o(Ee,es),o(A,os),o(A,j),R(ke,j,null),o(j,ts),o(j,V),o(V,ss),o(V,Ge),o(Ge,ns),o(V,rs),o(V,_o),o(_o,as),o(V,is),o(j,ls),R(te,j,null),o(j,cs),R(se,j,null),u(e,Lo,d),u(e,W,d),o(W,ne),o(ne,wo),R(Ce,wo,null),o(W,ds),o(W,So),o(So,ps),u(e,Uo,d),u(e,I,d),R(Me,I,null),o(I,ms),o(I,vo),o(vo,hs),o(I,us),o(I,Ae),o(Ae,fs),o(Ae,qe),o(qe,gs),o(Ae,_s),o(I,ws),o(I,k),R(Fe,k,null),o(k,Ss),o(k,H),o(H,vs),o(H,Ye),o(Ye,bs),o(H,Rs),o(H,bo),o(bo,$s),o(H,ys),o(k,Ts),R(re,k,null),o(k,xs),R(ae,k,null),Vo=!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}),se.$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){Vo||($(a.$$.fragment,e),$(me.$$.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),$(se.$$.fragment,e),$(Ce.$$.fragment,e),$(Me.$$.fragment,e),$(Fe.$$.fragment,e),$(re.$$.fragment,e),$(ae.$$.fragment,e),Vo=!0)},o(e){y(a.$$.fragment,e),y(me.$$.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(se.$$.fragment,e),y(Ce.$$.fragment,e),y(Me.$$.fragment,e),y(Fe.$$.fragment,e),y(re.$$.fragment,e),y(ae.$$.fragment,e),Vo=!1},d(e){t(p),e&&t(S),e&&t(_),T(a),e&&t(To),e&&t(F),T(me),e&&t(xo),e&&t(E),e&&t(Io),e&&t(Ue),e&&t(Po),e&&t(Ve),e&&t(Eo),e&&t(J),e&&t(jo),e&&t(fe),e&&t(ko),e&&t(q),e&&t(Co),e&&t(z),T(we),e&&t(Mo),e&&t(Y),e&&t(Ao),e&&t(X),e&&t(qo),e&&t(N),T(be),e&&t(Fo),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(se),e&&t(Lo),e&&t(W),T(Ce),e&&t(Uo),e&&t(I),T(Me),T(Fe),T(re),T(ae)}}}const An={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 qn(P){return In(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Un extends Rn{constructor(p){super();$n(this,p,qn,Mn,yn,{})}}export{Un as default,An as metadata};
