SKT27182 commited on
Commit
700a2d4
·
1 Parent(s): 4d3c0ea

Changed the initial values

Browse files
Files changed (2) hide show
  1. .gitignore +1 -0
  2. app.py +37 -36
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ __pycache__
app.py CHANGED
@@ -30,15 +30,15 @@ def change_dtype_inputs(
30
  def fit_style_transfer(
31
  style_image,
32
  content_image,
33
- extractor="inception_v3",
34
- n_style_layers=2,
35
- n_content_layers=3,
36
- epochs=4,
37
- learning_rate=60.0,
38
- steps_per_epoch=100,
39
- style_weight=0.3,
40
- content_weight=0.5,
41
- var_weight=1e-12,
42
  ):
43
  """
44
  Fit the style transfer model to the content and style images.
@@ -127,7 +127,7 @@ def fit_style_transfer(
127
 
128
  optimizer = tf.optimizers.Adam(
129
  tf.keras.optimizers.schedules.ExponentialDecay(
130
- initial_learning_rate=learning_rate, decay_steps=100, decay_rate=0.80
131
  )
132
  )
133
 
@@ -187,37 +187,37 @@ def main():
187
 
188
  epochs = gr.Slider(2, 20, value=4, step=1, label="Epochs")
189
 
190
- learning_rate = gr.Slider(1, 100, value=60, step=1, label="Learning Rate")
191
 
192
  steps_per_epoch = gr.Slider(
193
  1,
194
- 100,
195
- value=80,
196
  step=1,
197
  label="Steps Per Epoch",
198
  )
199
 
200
  style_weight = gr.Slider(
201
  1e-4,
202
- 0.5,
203
- value=0.3,
204
  step=1e-4,
205
  label="Style Weight",
206
  )
207
 
208
  content_weight = gr.Slider(
209
  1e-3,
210
- 0.5,
211
- value=0.5,
212
  step=1e-4,
213
  label="Content Weight",
214
  )
215
 
216
  var_weight = gr.Slider(
217
  0,
218
- 1e-5,
219
- value=1e-7,
220
- step=1e-12,
221
  label="Total Variation Weight",
222
  )
223
 
@@ -241,13 +241,13 @@ def main():
241
  "examples/content_1.jpg",
242
  "inception_v3",
243
  3,
244
- 2,
245
- 4,
246
- 60,
247
- 100,
248
- 0.3,
249
- 0.5,
250
- 1e-8,
251
  ],
252
  [
253
  "examples/style_2.jpg",
@@ -257,23 +257,24 @@ def main():
257
  2,
258
  4,
259
  60,
260
- 100,
261
- 0.3,
262
- 0.5,
263
- 1e-5,
264
  ],
 
265
  [
266
  "examples/style_3.jpg",
267
  "examples/content_3.jpg",
268
  "inception_v3",
269
  3,
270
- 2,
271
  4,
272
  60,
273
- 100,
274
- 0.5,
275
- 0.3,
276
- 1e-10,
277
  ]
278
 
279
  ]
 
30
  def fit_style_transfer(
31
  style_image,
32
  content_image,
33
+ extractor,
34
+ n_style_layers,
35
+ n_content_layers,
36
+ epochs,
37
+ learning_rate,
38
+ steps_per_epoch,
39
+ style_weight,
40
+ content_weight,
41
+ var_weight,
42
  ):
43
  """
44
  Fit the style transfer model to the content and style images.
 
127
 
128
  optimizer = tf.optimizers.Adam(
129
  tf.keras.optimizers.schedules.ExponentialDecay(
130
+ initial_learning_rate=learning_rate, decay_steps=100, decay_rate=0.50
131
  )
132
  )
133
 
 
187
 
188
  epochs = gr.Slider(2, 20, value=4, step=1, label="Epochs")
189
 
190
+ learning_rate = gr.Slider(1, 50, value=20, step=1, label="Learning Rate")
191
 
192
  steps_per_epoch = gr.Slider(
193
  1,
194
+ 10,
195
+ value=5,
196
  step=1,
197
  label="Steps Per Epoch",
198
  )
199
 
200
  style_weight = gr.Slider(
201
  1e-4,
202
+ 1e-1,
203
+ value=5e-2,
204
  step=1e-4,
205
  label="Style Weight",
206
  )
207
 
208
  content_weight = gr.Slider(
209
  1e-3,
210
+ 1e-1,
211
+ value=3e-2,
212
  step=1e-4,
213
  label="Content Weight",
214
  )
215
 
216
  var_weight = gr.Slider(
217
  0,
218
+ 3,
219
+ value=1.5,
220
+ step=0.2,
221
  label="Total Variation Weight",
222
  )
223
 
 
241
  "examples/content_1.jpg",
242
  "inception_v3",
243
  3,
244
+ 1,
245
+ 5,
246
+ 80,
247
+ 10,
248
+ 2e-2,
249
+ 1e-2,
250
+ 1.5,
251
  ],
252
  [
253
  "examples/style_2.jpg",
 
257
  2,
258
  4,
259
  60,
260
+ 10,
261
+ 5e-2,
262
+ 3e-2,
263
+ 1.5,
264
  ],
265
+
266
  [
267
  "examples/style_3.jpg",
268
  "examples/content_3.jpg",
269
  "inception_v3",
270
  3,
271
+ 1,
272
  4,
273
  60,
274
+ 10,
275
+ 5e-2,
276
+ 3e-2,
277
+ 1.5,
278
  ]
279
 
280
  ]