jemartin commited on
Commit
1e89ed7
·
verified ·
1 Parent(s): 954eb23

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +69 -0
README.md ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: apache-2.0
4
+ model_name: super-resolution-10.onnx
5
+ tags:
6
+ - validated
7
+ - vision
8
+ - super_resolution
9
+ - sub_pixel_cnn_2016
10
+ ---
11
+ <!--- SPDX-License-Identifier: Apache-2.0 -->
12
+
13
+ # Super Resolution
14
+
15
+ ## Use cases
16
+ The Super Resolution machine learning model sharpens and upscales the input image to refine the details and improve quality.
17
+
18
+ ## Description
19
+ Super Resolution uses efficient [Sub-pixel convolutional layer](https://arxiv.org/abs/1609.05158) described for increasing spatial resolution within network tasks. By increasing pixel count, images are then clarified, sharpened, and upscaled without losing the input image’s content and characteristics.
20
+
21
+ ## Model
22
+
23
+ |Model |Download |Download (with sample test data)| ONNX version | Opset Version|
24
+ |-------------|:--------------|:--------------|:--------------| :------------|
25
+ |Super_Resolution| [240 KB](model/super-resolution-10.onnx) | [7.6 MB](model/super-resolution-10.tar.gz) | 1.5.0 | 10|
26
+
27
+ ## Inference
28
+ Get started with this model by running through the [included inference notebook](dependencies/Run_Super_Resolution_Model.ipynb) for Super Resolution or following the steps below.
29
+
30
+ ### Input
31
+ Image input sizes are dynamic. The inference was done using jpg image.
32
+
33
+ ### Preprocessing
34
+ Images are resized into (224x224). The image format is changed into YCbCr with color components: greyscale ‘Y’, blue-difference ‘Cb’, and red-difference ‘Cr’. Once the greyscale Y component is extracted, it is then passed through the super resolution model and upscaled.
35
+
36
+ from PIL import Image
37
+ from resizeimage import resizeimage
38
+ import numpy as np
39
+ orig_img = Image.open('IMAGE_FILE_PATH')
40
+ img = resizeimage.resize_cover(orig_img, [224,224], validate=False)
41
+ img_ycbcr = img.convert('YCbCr')
42
+ img_y_0, img_cb, img_cr = img_ycbcr.split()
43
+ img_ndarray = np.asarray(img_y_0)
44
+ img_4 = np.expand_dims(np.expand_dims(img_ndarray, axis=0), axis=0)
45
+ img_5 = img_4.astype(np.float32) / 255.0
46
+ img_5
47
+
48
+
49
+ ### Output
50
+ The model outputs a multidimensional array of pixels that are upscaled. Output shape is [batch_size,1,672,672]. The second dimension is one because only the (Y) intensity channel was passed into the super resolution model and upscaled.
51
+
52
+ ### Postprocessing
53
+ Postprocessing involves converting the array of pixels into an image that is scaled to a higher resolution. The color channels (Cb, Cr) are also scaled to a higher resolution using bicubic interpolation. Then the color channels are combined and converted back to RGB format, producing the final output image.
54
+
55
+ final_img = Image.merge(
56
+ "YCbCr", [
57
+ img_out_y,
58
+ img_cb.resize(img_out_y.size, Image.BICUBIC),
59
+ img_cr.resize(img_out_y.size, Image.BICUBIC),
60
+ ]).convert("RGB")
61
+ plt.imshow(final_img)
62
+
63
+
64
+ ## Dataset
65
+ This model is trained on the [BSD300 Dataset](https://github.com/pytorch/examples/tree/master/super_resolution), using crops from the 200 training images.
66
+
67
+ ## Training
68
+ View the [training notebook](https://github.com/pytorch/examples/tree/master/super_resolution) to understand details for parameters and network for SuperResolution.
69
+