File size: 1,087 Bytes
687e8c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import torch
import torch.nn as nn

class SimpleUpscaleModel(nn.Module):
    def __init__(self, scale_factor=2):
        """
        A simple model for upscaling inputs using bilinear interpolation.
        
        Args:
            scale_factor (int): The factor by which to upscale the input.
        """
        super(SimpleUpscaleModel, self).__init__()
        
        # Upsampling layer
        self.upsample = nn.Upsample(scale_factor=scale_factor, mode='bilinear', align_corners=True)
    
    def forward(self, x):
        """
        Forward pass of the network.
        
        Args:
            x (torch.Tensor): Input tensor of shape (batch_size, channels, height, width).
        
        Returns:
            torch.Tensor: Upscaled output tensor.
        """
        return self.upsample(x)

if __name__ == "__main__":
    # Create the model
    scale_factor = 2
    model = SimpleUpscaleModel(scale_factor=scale_factor)

    # Save the model
    model_path = "model_weights.pth"
    torch.save(model.state_dict(), model_path)

    print(f"Model saved to {model_path}")