IndranilB commited on
Commit
4eef8da
·
verified ·
1 Parent(s): e1f554a

Initial release of DFRNet-v1 Baseline

Browse files
DFRNet-v1-best_model.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4493dd1b8398752afa41d7e80222f8ddeacdddf17565e4510ddef510c3bdba18
3
+ size 48661
README.md ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: mit
5
+ library_name: pytorch
6
+ pipeline_tag: image-to-image
7
+ tags:
8
+ - image-restoration
9
+ - image-denoising
10
+ - super-resolution
11
+ - image-enhancement
12
+ - image-to-image
13
+ - computer-vision
14
+ - deep-learning
15
+ - pytorch
16
+ ---
17
+
18
+ # DFRNet-v1 — Baseline
19
+
20
+ ## Overview
21
+
22
+ DFRNet-v1 is a lightweight convolutional neural network developed as
23
+ the baseline architecture for the DFRNet image restoration project.
24
+
25
+ The model is designed as an image-to-image learning system. It accepts
26
+ a three-channel RGB image, transforms it through a convolutional
27
+ encoder, and reconstructs the output at a fixed resolution of
28
+ **640 × 1024 pixels**.
29
+
30
+ The broader DFRNet project explores deep learning approaches for:
31
+
32
+ - Image restoration
33
+ - Image denoising
34
+ - Image enhancement
35
+ - Resolution enhancement
36
+ - Super-resolution
37
+
38
+ This release represents the initial baseline architecture and provides
39
+ a reference point for future architectural experiments.
40
+
41
+ ---
42
+
43
+ ## How It Works
44
+
45
+ The model follows a simple encoder-decoder pipeline:
46
+
47
+ Input RGB Image
48
+ |
49
+ v
50
+ Convolutional Encoder
51
+ |
52
+ v
53
+ Feature Transformation
54
+ |
55
+ v
56
+ Bilinear Upsampling
57
+ |
58
+ v
59
+ Output Image
60
+ 640 × 1024
61
+
62
+ The encoder extracts and transforms visual features using convolutional
63
+ layers. The decoder then uses bilinear interpolation to reconstruct the
64
+ three-channel representation at the required output resolution.
65
+
66
+ ---
67
+
68
+ ## Architecture
69
+
70
+ The model contains two main components:
71
+
72
+ ### Encoder
73
+
74
+ The encoder progressively transforms the channel representation:
75
+
76
+ 3 → 9 → 27 → 3
77
+
78
+ It consists of:
79
+
80
+ 1. ConvBlock: 3 → 9 channels
81
+ 2. ConvBlock: 9 → 27 channels
82
+ 3. Conv2D: 27 → 3 channels
83
+
84
+ Each ConvBlock follows:
85
+
86
+ Conv2D (3×3)
87
+ |
88
+ ReLU
89
+ |
90
+ Conv2D (3×3)
91
+ |
92
+ ReLU
93
+
94
+ All convolutional layers use 3×3 kernels with padding=1, preserving
95
+ the spatial dimensions during convolution.
96
+
97
+ ### Decoder
98
+
99
+ The decoder uses bilinear interpolation:
100
+
101
+ Output resolution: 640 × 1024
102
+
103
+ The decoder contains no additional learnable parameters.
104
+
105
+ ---
106
+
107
+ ## Model Statistics
108
+
109
+ | Property | Value |
110
+ |---|---|
111
+ | Architecture | ImageRegressionNet |
112
+ | Framework | PyTorch |
113
+ | Input Channels | 3 |
114
+ | Channel Progression | 3 → 9 → 27 → 3 |
115
+ | Activation | ReLU |
116
+ | Convolution Kernel | 3×3 |
117
+ | Decoder | Bilinear Upsampling |
118
+ | Output Resolution | 640 × 1024 |
119
+ | Total Parameters | 10,524 |
120
+ | Trainable Parameters | 10,524 |
121
+
122
+ ---
123
+
124
+ ## Repository Contents
125
+
126
+ DFRNet-v1-Baseline/
127
+
128
+ ├── DFRNet-v1-best_model.pth
129
+ │ Trained PyTorch model weights
130
+
131
+ ├── model.py
132
+ │ Complete model architecture
133
+
134
+ ├── architecture.txt
135
+ │ Detailed architecture explanation
136
+
137
+ ├── model_summary.txt
138
+ │ Layer-by-layer model summary
139
+
140
+ ├── requirements.txt
141
+ │ Required dependencies
142
+
143
+ └── README.md
144
+ Model documentation
145
+
146
+ ---
147
+
148
+ ## Installation
149
+
150
+ Install the required dependencies:
151
+
152
+ pip install -r requirements.txt
153
+
154
+ ---
155
+
156
+ ## Loading the Model
157
+
158
+ ```python
159
+ import torch
160
+
161
+ from model import ImageRegressionNet
162
+
163
+
164
+ device = torch.device(
165
+ "cuda" if torch.cuda.is_available() else "cpu"
166
+ )
167
+
168
+ model = ImageRegressionNet().to(device)
169
+
170
+ checkpoint = torch.load(
171
+ "DFRNet-v1-best_model.pth",
172
+ map_location=device
173
+ )
174
+
175
+ model.load_state_dict(checkpoint)
176
+
177
+ model.eval()
178
+ ````
179
+
180
+ ---
181
+
182
+ ## Basic Inference
183
+
184
+ ```python
185
+ with torch.no_grad():
186
+ output = model(input_tensor)
187
+ ```
188
+
189
+ The model expects an input tensor in the format:
190
+
191
+ ```
192
+ [B, 3, H, W]
193
+ ```
194
+
195
+ where:
196
+
197
+ * B is the batch size
198
+ * 3 represents RGB channels
199
+ * H is the image height
200
+ * W is the image width
201
+
202
+ The output shape is:
203
+
204
+ ```
205
+ [B, 3, 640, 1024]
206
+ ```
207
+
208
+ ---
209
+
210
+ ## Important: Preprocessing
211
+
212
+ For reliable inference, the preprocessing pipeline should match the
213
+ pipeline used during training.
214
+
215
+ Important considerations include:
216
+
217
+ * Image resizing
218
+ * RGB channel ordering
219
+ * Tensor conversion
220
+ * Pixel scaling
221
+ * Normalization
222
+
223
+ Using a significantly different preprocessing pipeline may affect
224
+ model performance.
225
+
226
+ ---
227
+
228
+ ## Intended Use
229
+
230
+ DFRNet-v1 is intended primarily for:
231
+
232
+ * Academic experimentation
233
+ * Deep learning research
234
+ * Image restoration experiments
235
+ * Image denoising experiments
236
+ * Image-to-image regression research
237
+ * Architecture experimentation
238
+
239
+ This version should be considered a baseline research model.
240
+
241
+ ---
242
+
243
+ ## Limitations
244
+
245
+ DFRNet-v1 is intentionally lightweight and designed as an initial
246
+ baseline architecture.
247
+
248
+ Limitations include:
249
+
250
+ * Limited representational capacity compared with deeper models
251
+ * Dependence on the training data distribution
252
+ * Limited generalization to unseen degradation patterns
253
+ * No residual connections
254
+ * No skip connections
255
+ * No multi-scale feature extraction
256
+ * No attention mechanisms
257
+
258
+ These limitations provide opportunities for future versions of DFRNet.
259
+
260
+ ---
261
+
262
+ ## Future Directions
263
+
264
+ Future versions may explore:
265
+
266
+ * Residual learning
267
+ * Skip connections
268
+ * Multi-scale feature extraction
269
+ * Attention mechanisms
270
+ * Improved encoder-decoder architectures
271
+ * Improved reconstruction losses
272
+ * Perceptual losses
273
+ * Advanced denoising strategies
274
+ * Improved super-resolution approaches
275
+
276
+ ---
277
+
278
+ ## Project Philosophy
279
+
280
+ DFRNet is an iterative deep learning experimentation project.
281
+
282
+ The objective is not only to develop increasingly capable image
283
+ restoration models, but also to document the technical journey behind
284
+ their development.
285
+
286
+ This includes:
287
+
288
+ * Architectural decisions
289
+ * Baseline experiments
290
+ * Model behaviour
291
+ * Failure cases
292
+ * Architectural modifications
293
+ * Experimental comparisons
294
+ * Performance improvements
295
+ * Lessons learned
296
+
297
+ Each version of DFRNet represents a stage in this ongoing development
298
+ and experimentation process.
299
+
300
+ ---
301
+
302
+ ## Version
303
+
304
+ **DFRNet-v1 — Baseline**
305
+
306
+ ---
307
+
308
+ ## Author
309
+
310
+ **Indranil Bhattacharyya**
311
+
312
+ Independent deep learning research and experimentation project focused
313
+ on image restoration, denoising, and resolution enhancement.
314
+
315
+ ---
316
+
317
+ ## Disclaimer
318
+
319
+ This model is provided primarily for research, educational, and
320
+ experimental purposes.
321
+
322
+ Performance may vary depending on the characteristics of the input
323
+ images, degradation patterns, preprocessing pipeline, and similarity
324
+ between inference data and the training distribution.
__pycache__/model.cpython-312.pyc ADDED
Binary file (3.55 kB). View file
 
architecture.txt ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ DFRNet-v1 Baseline
2
+ ==================
3
+
4
+ OVERVIEW
5
+ --------
6
+
7
+ DFRNet-v1 is a lightweight convolutional image-to-image network
8
+ developed as a baseline for image restoration experiments.
9
+
10
+ The model takes an RGB image as input and transforms it through
11
+ convolutional feature extraction layers.
12
+
13
+ The encoder progressively changes the channel representation:
14
+
15
+ RGB Input
16
+ 3 channels
17
+ |
18
+ v
19
+ 9 channels
20
+ |
21
+ v
22
+ 27 channels
23
+ |
24
+ v
25
+ 3 channels
26
+
27
+ The resulting three-channel representation is passed to the decoder.
28
+
29
+ The decoder uses bilinear interpolation to resize the output to:
30
+
31
+ Height: 640 pixels
32
+ Width: 1024 pixels
33
+
34
+
35
+ ARCHITECTURE
36
+ ------------
37
+
38
+ Input RGB Image
39
+ |
40
+ v
41
+
42
+ Encoder
43
+ |
44
+ +-- ConvBlock: 3 -> 9
45
+ |
46
+ +-- ConvBlock: 9 -> 27
47
+ |
48
+ +-- Conv2D: 27 -> 3
49
+
50
+ |
51
+ v
52
+
53
+ Decoder
54
+ |
55
+ +-- Bilinear Upsampling
56
+ Output: 640 x 1024
57
+
58
+ |
59
+ v
60
+
61
+ Reconstructed Output Image
62
+
63
+
64
+ CONVBLOCK
65
+ ---------
66
+
67
+ Each ConvBlock contains:
68
+
69
+ Conv2D (3x3)
70
+ |
71
+ v
72
+ ReLU
73
+ |
74
+ v
75
+ Conv2D (3x3)
76
+ |
77
+ v
78
+ ReLU
79
+
80
+
81
+ MODEL STATISTICS
82
+ ----------------
83
+
84
+ Total Parameters:
85
+ 10,524
86
+
87
+ Trainable Parameters:
88
+ 10,524
89
+
90
+
91
+ PYTORCH MODEL
92
+ -------------
93
+
94
+ ImageRegressionNet(
95
+ (encoder): Encoder(
96
+ (stage_1): ConvBlock(
97
+ (block): Sequential(
98
+ (0): Conv2d(3, 9, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
99
+ (1): ReLU(inplace=True)
100
+ (2): Conv2d(9, 9, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
101
+ (3): ReLU(inplace=True)
102
+ )
103
+ )
104
+ (stage_2): ConvBlock(
105
+ (block): Sequential(
106
+ (0): Conv2d(9, 27, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
107
+ (1): ReLU(inplace=True)
108
+ (2): Conv2d(27, 27, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
109
+ (3): ReLU(inplace=True)
110
+ )
111
+ )
112
+ (stage_3): Conv2d(27, 3, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
113
+ )
114
+ (decoder): Decoder(
115
+ (upsample_block): Upsample(size=(640, 1024), mode='bilinear')
116
+ )
117
+ (encoder_decoder): Sequential(
118
+ (0): Encoder(
119
+ (stage_1): ConvBlock(
120
+ (block): Sequential(
121
+ (0): Conv2d(3, 9, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
122
+ (1): ReLU(inplace=True)
123
+ (2): Conv2d(9, 9, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
124
+ (3): ReLU(inplace=True)
125
+ )
126
+ )
127
+ (stage_2): ConvBlock(
128
+ (block): Sequential(
129
+ (0): Conv2d(9, 27, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
130
+ (1): ReLU(inplace=True)
131
+ (2): Conv2d(27, 27, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
132
+ (3): ReLU(inplace=True)
133
+ )
134
+ )
135
+ (stage_3): Conv2d(27, 3, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
136
+ )
137
+ (1): Decoder(
138
+ (upsample_block): Upsample(size=(640, 1024), mode='bilinear')
139
+ )
140
+ )
141
+ )
model.py ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import torch
3
+ import torch.nn as nn
4
+
5
+
6
+ class ConvBlock(nn.Module):
7
+
8
+ def __init__(self, in_channels, out_channels):
9
+ super().__init__()
10
+
11
+ self.block = nn.Sequential(
12
+ nn.Conv2d(
13
+ in_channels,
14
+ out_channels,
15
+ kernel_size=3,
16
+ padding=1
17
+ ),
18
+ nn.ReLU(inplace=True),
19
+
20
+ nn.Conv2d(
21
+ out_channels,
22
+ out_channels,
23
+ kernel_size=3,
24
+ padding=1
25
+ ),
26
+ nn.ReLU(inplace=True)
27
+ )
28
+
29
+ def forward(self, x):
30
+ return self.block(x)
31
+
32
+
33
+ class Encoder(nn.Module):
34
+
35
+ def __init__(self):
36
+ super().__init__()
37
+
38
+ self.stage_1 = ConvBlock(
39
+ in_channels=3,
40
+ out_channels=9
41
+ )
42
+
43
+ self.stage_2 = ConvBlock(
44
+ in_channels=9,
45
+ out_channels=27
46
+ )
47
+
48
+ self.stage_3 = nn.Conv2d(
49
+ in_channels=27,
50
+ out_channels=3,
51
+ kernel_size=3,
52
+ padding=1
53
+ )
54
+
55
+ def forward(self, x):
56
+
57
+ x = self.stage_1(x)
58
+ x = self.stage_2(x)
59
+ x = self.stage_3(x)
60
+
61
+ return x
62
+
63
+
64
+ class Decoder(nn.Module):
65
+
66
+ def __init__(self):
67
+ super().__init__()
68
+
69
+ self.upsample_block = nn.Upsample(
70
+ size=(640, 1024),
71
+ mode="bilinear",
72
+ align_corners=False
73
+ )
74
+
75
+ def forward(self, x):
76
+ return self.upsample_block(x)
77
+
78
+
79
+ class ImageRegressionNet(nn.Module):
80
+
81
+ def __init__(self):
82
+ super().__init__()
83
+
84
+ self.encoder = Encoder()
85
+
86
+ self.decoder = Decoder()
87
+
88
+ self.encoder_decoder = nn.Sequential(
89
+ self.encoder,
90
+ self.decoder
91
+ )
92
+
93
+ def forward(self, x):
94
+ return self.encoder_decoder(x)
model_summary.txt ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ==========================================================================================
2
+ Layer (type:depth-idx) Output Shape Param #
3
+ ==========================================================================================
4
+ ImageRegressionNet [1, 3, 640, 1024] --
5
+ ├─Sequential: 1-1 [1, 3, 640, 1024] --
6
+ │ └─Encoder: 2-1 [1, 3, 640, 1024] --
7
+ │ │ └─ConvBlock: 3-1 [1, 9, 640, 1024] 990
8
+ │ │ └─ConvBlock: 3-2 [1, 27, 640, 1024] 8,802
9
+ │ │ └─Conv2d: 3-3 [1, 3, 640, 1024] 732
10
+ │ └─Decoder: 2-2 [1, 3, 640, 1024] --
11
+ │ │ └─Upsample: 3-4 [1, 3, 640, 1024] --
12
+ ==========================================================================================
13
+ Total params: 10,524
14
+ Trainable params: 10,524
15
+ Non-trainable params: 0
16
+ Total mult-adds (Units.GIGABYTES): 6.90
17
+ ==========================================================================================
18
+ Input size (MB): 7.86
19
+ Forward/backward pass size (MB): 393.22
20
+ Params size (MB): 0.04
21
+ Estimated Total Size (MB): 401.12
22
+ ==========================================================================================
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ torch>=2.0.0
2
+ torchvision>=0.15.0
3
+ numpy
4
+ Pillow