Update app.py
Browse files
app.py
CHANGED
|
@@ -67,7 +67,7 @@ def get_loss_and_gradient(model, inputs, total_variation_weight=0):
|
|
| 67 |
return loss, grads
|
| 68 |
|
| 69 |
|
| 70 |
-
def run_gradient_ascent(model, inputs, progress_bar epochs=1, steps_per_epoch=1, weight=0.05, total_variation_weight=0):
|
| 71 |
img = tf.convert_to_tensor(inputs)
|
| 72 |
for i in range(epochs):
|
| 73 |
for _ in range(steps_per_epoch):
|
|
@@ -126,7 +126,7 @@ if uploaded_file is not None:
|
|
| 126 |
progress_bar = st.progress(0.0) # Initialize progress bar
|
| 127 |
|
| 128 |
# Run gradient ascent
|
| 129 |
-
image_array = run_gradient_ascent(dream_model, preprocessed_image, progress_bar epochs=epochs, steps_per_epoch=steps_per_epoch, weight=weight)
|
| 130 |
|
| 131 |
# Convert numpy arrays to PIL images
|
| 132 |
dream_pil_image = array_to_img(deprocess_inception_image(image_array))
|
|
|
|
| 67 |
return loss, grads
|
| 68 |
|
| 69 |
|
| 70 |
+
def run_gradient_ascent(model, inputs, progress_bar, epochs=1, steps_per_epoch=1, weight=0.05, total_variation_weight=0):
|
| 71 |
img = tf.convert_to_tensor(inputs)
|
| 72 |
for i in range(epochs):
|
| 73 |
for _ in range(steps_per_epoch):
|
|
|
|
| 126 |
progress_bar = st.progress(0.0) # Initialize progress bar
|
| 127 |
|
| 128 |
# Run gradient ascent
|
| 129 |
+
image_array = run_gradient_ascent(dream_model, preprocessed_image, progress_bar, epochs=epochs, steps_per_epoch=steps_per_epoch, weight=weight)
|
| 130 |
|
| 131 |
# Convert numpy arrays to PIL images
|
| 132 |
dream_pil_image = array_to_img(deprocess_inception_image(image_array))
|