Spaces:
Sleeping
Sleeping
Changed the initial values
Browse files- .gitignore +1 -0
- 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
|
| 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,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.
|
| 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,
|
| 191 |
|
| 192 |
steps_per_epoch = gr.Slider(
|
| 193 |
1,
|
| 194 |
-
|
| 195 |
-
value=
|
| 196 |
step=1,
|
| 197 |
label="Steps Per Epoch",
|
| 198 |
)
|
| 199 |
|
| 200 |
style_weight = gr.Slider(
|
| 201 |
1e-4,
|
| 202 |
-
|
| 203 |
-
value=
|
| 204 |
step=1e-4,
|
| 205 |
label="Style Weight",
|
| 206 |
)
|
| 207 |
|
| 208 |
content_weight = gr.Slider(
|
| 209 |
1e-3,
|
| 210 |
-
|
| 211 |
-
value=
|
| 212 |
step=1e-4,
|
| 213 |
label="Content Weight",
|
| 214 |
)
|
| 215 |
|
| 216 |
var_weight = gr.Slider(
|
| 217 |
0,
|
| 218 |
-
|
| 219 |
-
value=
|
| 220 |
-
step=
|
| 221 |
label="Total Variation Weight",
|
| 222 |
)
|
| 223 |
|
|
@@ -241,13 +241,13 @@ def main():
|
|
| 241 |
"examples/content_1.jpg",
|
| 242 |
"inception_v3",
|
| 243 |
3,
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
],
|
| 252 |
[
|
| 253 |
"examples/style_2.jpg",
|
|
@@ -257,23 +257,24 @@ def main():
|
|
| 257 |
2,
|
| 258 |
4,
|
| 259 |
60,
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
],
|
|
|
|
| 265 |
[
|
| 266 |
"examples/style_3.jpg",
|
| 267 |
"examples/content_3.jpg",
|
| 268 |
"inception_v3",
|
| 269 |
3,
|
| 270 |
-
|
| 271 |
4,
|
| 272 |
60,
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 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 |
]
|