Skip to content

Commit bae6489

Browse files
committed
Starting structure of blog
1 parent c3d5131 commit bae6489

File tree

2 files changed

+124
-48
lines changed

2 files changed

+124
-48
lines changed

Diff for: .ipynb_checkpoints/Blog for CycleGan-checkpoint.ipynb

+62-24
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,84 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Cross Domain Image Transfer\n",
8-
"\n",
9-
"In this blog, We will try to understand different aspects of cross domain image transfer and then I will try to explain recent research paper by Kim et. al https://arxiv.org/pdf/1703.05192v1.pdf."
7+
"Cross domain image transfer has been a hot topic and various models have been used to acheive this task. Recenetly, realising the power of GAN networks people have started making model based on GANs and the results are quite impressive. In this blog, we will try to understand the recent development in this direction by Kim et. al https://arxiv.org/pdf/1703.05192v1.pdf."
108
]
119
},
1210
{
1311
"cell_type": "markdown",
14-
"metadata": {},
12+
"metadata": {
13+
"collapsed": true
14+
},
1515
"source": [
16-
"So let us first look at the basic structure of blog\n",
16+
"There are various components of transferring an image from one cateogry to another category. So let us first look at these things in detail\n",
1717
"\n",
18-
"1.) First we will try to understand the problem statement\n",
18+
"1.) Extracting the features of an image (Decoding): So, first of all what do we mean by features of an image. Suppose we want to convert an image of man to a look-alike woman, first, we need to understand various general things about the human face like this thing is nose, or ear, or eyebrows or hair etc. These are some high level features but there are some low level features like edges and curves. Using these low level features only we recongise these high level features which help use break down the image and understand the details of it. Model that is used to extract these features almost in all neutral network is call Convolution Network which you can read in detail about in this paper: [Link to nice blog post on Convolution]\n",
1919
"\n",
20-
"2.) Second we will look at the high-level architecture\n",
2120
"\n",
22-
"3.) Understand the loss function and how it helps in solving the problem statement.\n",
2321
"\n",
24-
"4.) Finally we will look at the architecture of the Neural Netwroks, its various elements and what do they signify."
25-
]
26-
},
27-
{
28-
"cell_type": "markdown",
29-
"metadata": {},
30-
"source": [
31-
"# Problem Statement\n",
22+
"2.) Learning transformation from the feature of one model to that of another model (Transfer): After first step, we have high and low level features of an image and we would like to convert these details to that of another category. Let us look at one of these transformatin that we need to learn. Suppose we detected that a man's face has some beard and we like to convert this face to that of a woman then we need to remove the beard and smothen out that part of face to match with color of face. Another example might include thick eyebrows to thin eyebrows and so on.\n",
3223
"\n",
33-
"Cross domain image transfer basically means converting an image from one domain, say, Chair to another domain of object, say cat, preserving the properties of original image like the shape/curve etc (depending on conversion we want to make). Otherwise we can simply have constant function that always outputs an image of same cat. But that is not interesting to us.\n",
3424
"\n",
35-
"Some interesting examples of this model transfer are:\n",
25+
"3.) Making the final image (Encoding): This step can bee send as the reversal of step 1. Here, we will look at different features of an image and construct a face out of it.\n",
3626
"\n",
37-
"1.) Converting an image of animal of one species to that of another one.\n",
38-
"2.) Making a look alike person of opposite gender. These days it is quite popular with apps like Faceapp. They have also used the Generative Adversial Network model to get the results\n",
39-
"3.) \n",
4027
"\n",
41-
"And the list long based on your imagination.\n",
28+
"Things need to keep in mind. We will not learn high level features like this is an ear or this part is nose because these are very high level features but maybe like this the upper part of nose or like this is left part of the left eyebrow and so on. Basically some mid level features.\n",
4229
"\n",
4330
"\n",
44-
"So, let us look at the key component of the problem:\n",
31+
"So, now that we have understood the key elements of an image transformation, let use see how they model this using neural network. Once, you are clear with these steps and have basic knowledge of Deep Learning you are good to go to make the model."
32+
]
33+
},
34+
{
35+
"cell_type": "markdown",
36+
"metadata": {},
37+
"source": [
38+
"Extracting the features:\n",
4539
"\n",
46-
"1.) Breaking down the key componets of an image. This can be done easily via the convolution networks that has now became integrated part of GAN models. In simple language Convolution networks look at the small patches of an images and extract differenct features out of it. We will go in detail in the later part of this blog about the convolution networks"
40+
"For the basic about convolution network you can go through this very intuitive blog post by []. So the first step is extracting 64 very low level features (using a window of [7,7]).This can easily be done via a conv layer as follow:"
41+
]
42+
},
43+
{
44+
"cell_type": "code",
45+
"execution_count": null,
46+
"metadata": {
47+
"collapsed": false
48+
},
49+
"outputs": [],
50+
"source": [
51+
"o_c1 = general_conv2d(input, 64, 7, 7, 1, 1)"
52+
]
53+
},
54+
{
55+
"cell_type": "markdown",
56+
"metadata": {},
57+
"source": [
58+
"Now, we can keep on extracting further features and since we dont want to blow up the size of image, we will use stride of 2. It will prevent overlapping as well as reduce the size of output. So, we further extract features as follow"
59+
]
60+
},
61+
{
62+
"cell_type": "code",
63+
"execution_count": null,
64+
"metadata": {
65+
"collapsed": true
66+
},
67+
"outputs": [],
68+
"source": [
69+
"o_c2 = general_conv2d(o_c1, 64*2, 3, 3, 2, 2)\n",
70+
"o_c3 = general_conv2d(o_c2, 64*4, 3, 3, 2, 2)"
71+
]
72+
},
73+
{
74+
"cell_type": "markdown",
75+
"metadata": {},
76+
"source": [
77+
"So, as you can see we are extracting more and more high-level features from the previous layer of low-level features moving towards extracting very high level features."
78+
]
79+
},
80+
{
81+
"cell_type": "markdown",
82+
"metadata": {},
83+
"source": [
84+
"So we can assume that after these step we will have fairly decent amount of features that we would like to transform to a woman's face. So we will build the transformation layers as follow. For these transformation we would like to maintain the same number of features, so the number of features of intermediate output of intermediate layers will be same."
4785
]
4886
},
4987
{

Diff for: Blog for CycleGan.ipynb

+62-24
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,84 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Cross Domain Image Transfer\n",
8-
"\n",
9-
"In this blog, We will try to understand different aspects of cross domain image transfer and then I will try to explain recent research paper by Kim et. al https://arxiv.org/pdf/1703.05192v1.pdf."
7+
"Cross domain image transfer has been a hot topic and various models have been used to acheive this task. Recenetly, realising the power of GAN networks people have started making model based on GANs and the results are quite impressive. In this blog, we will try to understand the recent development in this direction by Kim et. al https://arxiv.org/pdf/1703.05192v1.pdf."
108
]
119
},
1210
{
1311
"cell_type": "markdown",
14-
"metadata": {},
12+
"metadata": {
13+
"collapsed": true
14+
},
1515
"source": [
16-
"So let us first look at the basic structure of blog\n",
16+
"There are various components of transferring an image from one cateogry to another category. So let us first look at these things in detail\n",
1717
"\n",
18-
"1.) First we will try to understand the problem statement\n",
18+
"1.) Extracting the features of an image (Decoding): So, first of all what do we mean by features of an image. Suppose we want to convert an image of man to a look-alike woman, first, we need to understand various general things about the human face like this thing is nose, or ear, or eyebrows or hair etc. These are some high level features but there are some low level features like edges and curves. Using these low level features only we recongise these high level features which help use break down the image and understand the details of it. Model that is used to extract these features almost in all neutral network is call Convolution Network which you can read in detail about in this paper: [Link to nice blog post on Convolution]\n",
1919
"\n",
20-
"2.) Second we will look at the high-level architecture\n",
2120
"\n",
22-
"3.) Understand the loss function and how it helps in solving the problem statement.\n",
2321
"\n",
24-
"4.) Finally we will look at the architecture of the Neural Netwroks, its various elements and what do they signify."
25-
]
26-
},
27-
{
28-
"cell_type": "markdown",
29-
"metadata": {},
30-
"source": [
31-
"# Problem Statement\n",
22+
"2.) Learning transformation from the feature of one model to that of another model (Transfer): After first step, we have high and low level features of an image and we would like to convert these details to that of another category. Let us look at one of these transformatin that we need to learn. Suppose we detected that a man's face has some beard and we like to convert this face to that of a woman then we need to remove the beard and smothen out that part of face to match with color of face. Another example might include thick eyebrows to thin eyebrows and so on.\n",
3223
"\n",
33-
"Cross domain image transfer basically means converting an image from one domain, say, Chair to another domain of object, say cat, preserving the properties of original image like the shape/curve etc (depending on conversion we want to make). Otherwise we can simply have constant function that always outputs an image of same cat. But that is not interesting to us.\n",
3424
"\n",
35-
"Some interesting examples of this model transfer are:\n",
25+
"3.) Making the final image (Encoding): This step can bee send as the reversal of step 1. Here, we will look at different features of an image and construct a face out of it.\n",
3626
"\n",
37-
"1.) Converting an image of animal of one species to that of another one.\n",
38-
"2.) Making a look alike person of opposite gender. These days it is quite popular with apps like Faceapp. They have also used the Generative Adversial Network model to get the results\n",
39-
"3.) \n",
4027
"\n",
41-
"And the list long based on your imagination.\n",
28+
"Things need to keep in mind. We will not learn high level features like this is an ear or this part is nose because these are very high level features but maybe like this the upper part of nose or like this is left part of the left eyebrow and so on. Basically some mid level features.\n",
4229
"\n",
4330
"\n",
44-
"So, let us look at the key component of the problem:\n",
31+
"So, now that we have understood the key elements of an image transformation, let use see how they model this using neural network. Once, you are clear with these steps and have basic knowledge of Deep Learning you are good to go to make the model."
32+
]
33+
},
34+
{
35+
"cell_type": "markdown",
36+
"metadata": {},
37+
"source": [
38+
"Extracting the features:\n",
4539
"\n",
46-
"1.) Breaking down the key componets of an image. This can be done easily via the convolution networks that has now became integrated part of GAN models. In simple language Convolution networks look at the small patches of an images and extract differenct features out of it. We will go in detail in the later part of this blog about the convolution networks"
40+
"For the basic about convolution network you can go through this very intuitive blog post by []. So the first step is extracting 64 very low level features (using a window of [7,7]).This can easily be done via a conv layer as follow:"
41+
]
42+
},
43+
{
44+
"cell_type": "code",
45+
"execution_count": null,
46+
"metadata": {
47+
"collapsed": false
48+
},
49+
"outputs": [],
50+
"source": [
51+
"o_c1 = general_conv2d(input, 64, 7, 7, 1, 1)"
52+
]
53+
},
54+
{
55+
"cell_type": "markdown",
56+
"metadata": {},
57+
"source": [
58+
"Now, we can keep on extracting further features and since we dont want to blow up the size of image, we will use stride of 2. It will prevent overlapping as well as reduce the size of output. So, we further extract features as follow"
59+
]
60+
},
61+
{
62+
"cell_type": "code",
63+
"execution_count": null,
64+
"metadata": {
65+
"collapsed": true
66+
},
67+
"outputs": [],
68+
"source": [
69+
"o_c2 = general_conv2d(o_c1, 64*2, 3, 3, 2, 2)\n",
70+
"o_c3 = general_conv2d(o_c2, 64*4, 3, 3, 2, 2)"
71+
]
72+
},
73+
{
74+
"cell_type": "markdown",
75+
"metadata": {},
76+
"source": [
77+
"So, as you can see we are extracting more and more high-level features from the previous layer of low-level features moving towards extracting very high level features."
78+
]
79+
},
80+
{
81+
"cell_type": "markdown",
82+
"metadata": {},
83+
"source": [
84+
"So we can assume that after these step we will have fairly decent amount of features that we would like to transform to a woman's face. So we will build the transformation layers as follow. For these transformation we would like to maintain the same number of features, so the number of features of intermediate output of intermediate layers will be same."
4785
]
4886
},
4987
{

0 commit comments

Comments
 (0)