jemartin commited on
Commit
074b3c5
·
verified ·
1 Parent(s): bda26e3

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +91 -0
README.md ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: apache-2.0
4
+ model_name: candy-8.onnx
5
+ tags:
6
+ - validated
7
+ - vision
8
+ - style_transfer
9
+ - fast_neural_style
10
+ ---
11
+ <!--- SPDX-License-Identifier: BSD-3-Clause -->
12
+
13
+ # Fast Neural Style Transfer
14
+
15
+ ## Use-cases
16
+ This artistic style transfer model mixes the content of an image with the style of another image. Examples of the styles can be seen [in this PyTorch example](https://github.com/pytorch/examples/tree/master/fast_neural_style#models).
17
+
18
+
19
+ ## Description
20
+ The model uses the method described in [Perceptual Losses for Real-Time Style Transfer and Super-Resolution](https://arxiv.org/abs/1603.08155) along with [Instance Normalization](https://arxiv.org/pdf/1607.08022.pdf).
21
+
22
+
23
+ ## Model
24
+ |Model |Download |Download (with sample test data)|ONNX version|Opset version|
25
+ |-------------|:--------------|:--------------|:--------------|:--------------|
26
+ |Mosaic|[6.6 MB](model/mosaic-9.onnx) | [7.2 MB](model/mosaic-9.tar.gz)|1.4|9|
27
+ |Candy|[6.6 MB](model/candy-9.onnx) | [7.2 MB](model/candy-9.tar.gz)|1.4|9|
28
+ |Rain Princess|[6.6 MB](model/rain-princess-9.onnx) |[7.2 MB](model/rain-princess-9.tar.gz)|1.4|9|
29
+ |Udnie|[6.6 MB](model/udnie-9.onnx) | [7.2 MB](model/udnie-9.tar.gz)|1.4|9|
30
+ |Pointilism|[6.6 MB](model/pointilism-9.onnx) | [7.2 MB](model/pointilism-9.tar.gz)|1.4|9|
31
+ |Mosaic|[6.6 MB](model/mosaic-8.onnx) | [7.2 MB](model/mosaic-8.tar.gz)|1.4|8|
32
+ |Candy|[6.6 MB](model/candy-8.onnx) | [7.2 MB](model/candy-8.tar.gz)|1.4|8|
33
+ |Rain Princess|[6.6 MB](model/rain-princess-8.onnx) |[7.2 MB](model/rain-princess-8.tar.gz)|1.4|8|
34
+ |Udnie|[6.6 MB](model/udnie-8.onnx) | [7.2 MB](model/udnie-8.tar.gz)|1.4|8|
35
+ |Pointilism|[6.6 MB](model/pointilism-8.onnx) | [7.2 MB](model/pointilism-8.tar.gz)|1.4|8|
36
+ <hr>
37
+
38
+ ## Inference
39
+ Refer to [style-transfer-ort.ipynb](dependencies/style-transfer-ort.ipynb) for detailed preprocessing and postprocessing.
40
+
41
+ ### Input to model
42
+ The input to the model are 3-channel RGB images. The images have to be loaded in a range of [0, 255]. If running into memory issues, try resizing the image by increasing the scale number.
43
+
44
+ ### Preprocessing steps
45
+ ```
46
+ from PIL import Image
47
+ import numpy as np
48
+
49
+ # loading input and resize if needed
50
+ image = Image.open("PATH TO IMAGE")
51
+ size_reduction_factor = 1
52
+ image = image.resize((int(image.size[0] / size_reduction_factor), int(image.size[1] / size_reduction_factor)), Image.ANTIALIAS)
53
+
54
+ # Preprocess image
55
+ x = np.array(image).astype('float32')
56
+ x = np.transpose(x, [2, 0, 1])
57
+ x = np.expand_dims(x, axis=0)
58
+ ```
59
+
60
+ ### Output of model
61
+ The converted ONNX model outputs a NumPy float32 array of shape [1, 3, ‘height’, ‘width’]. The height and width of the output image are the same as the height and width of the input image.
62
+
63
+ ### Postprocessing steps
64
+ ```
65
+ result = np.clip(result, 0, 255)
66
+ result = result.transpose(1,2,0).astype("uint8")
67
+ img = Image.fromarray(result)
68
+ ```
69
+ <hr>
70
+
71
+ ## Dataset (Train and validation)
72
+ The original fast neural style model is from [pytorch/examples/fast_neural_style](https://github.com/pytorch/examples/tree/master/fast_neural_style). All models are trained using the [COCO 2014 Training images dataset](http://cocodataset.org/#download) [80K/13GB].
73
+ <hr>
74
+
75
+ ## Training
76
+ Refer to [pytorch/examples/fast_neural_style](https://github.com/pytorch/examples/tree/master/fast_neural_style) for training details in PyTorch. Refer to [conversion.ipynb](dependencies/conversion.ipynb) to learn how the PyTorch models are converted to ONNX format.
77
+ <hr>
78
+
79
+
80
+ ## References
81
+ Original style transfer model in PyTorch: <https://github.com/pytorch/examples/tree/master/fast_neural_style>
82
+ <hr>
83
+
84
+ ## Contributors
85
+ [Jennifer Wang](https://github.com/jennifererwangg)
86
+ <hr>
87
+
88
+ ## License
89
+ BSD-3-Clause
90
+ <hr>
91
+