Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
|
@@ -136,17 +136,17 @@ optimizer = keras.optimizers.SGD(
|
|
| 136 |
)
|
| 137 |
|
| 138 |
def get_imgs(base_image_path, style_reference_image_path):
|
| 139 |
-
base_image = preprocess_image(base_image_path)
|
| 140 |
-
style_reference_image = preprocess_image(style_reference_image_path)
|
| 141 |
-
combination_image = tf.Variable(preprocess_image(base_image_path))
|
| 142 |
-
|
| 143 |
# Dimensions of the generated picture.
|
| 144 |
-
width, height =
|
| 145 |
global img_nrows
|
| 146 |
global img_ncols
|
| 147 |
img_nrows = 400
|
| 148 |
img_ncols = int(width * img_nrows / height)
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
iterations = 400
|
| 151 |
for i in range(1, iterations + 1):
|
| 152 |
loss, grads = compute_loss_and_grads(combination_image, base_image, style_reference_image)
|
|
|
|
| 136 |
)
|
| 137 |
|
| 138 |
def get_imgs(base_image_path, style_reference_image_path):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
# Dimensions of the generated picture.
|
| 140 |
+
width, height = keras.preprocessing.image.load_img(base_image_path).size
|
| 141 |
global img_nrows
|
| 142 |
global img_ncols
|
| 143 |
img_nrows = 400
|
| 144 |
img_ncols = int(width * img_nrows / height)
|
| 145 |
|
| 146 |
+
base_image = preprocess_image(base_image_path)
|
| 147 |
+
style_reference_image = preprocess_image(style_reference_image_path)
|
| 148 |
+
combination_image = tf.Variable(preprocess_image(base_image_path))
|
| 149 |
+
|
| 150 |
iterations = 400
|
| 151 |
for i in range(1, iterations + 1):
|
| 152 |
loss, grads = compute_loss_and_grads(combination_image, base_image, style_reference_image)
|