Update app.py
Browse files
app.py
CHANGED
|
@@ -118,8 +118,17 @@ if uploaded_file is not None:
|
|
| 118 |
selected_layers = [f'mixed{i}' for i, checkbox in enumerate(layer_checkboxes, start=1) if checkbox]
|
| 119 |
dream_model = deep_dream_model(inception, selected_layers)
|
| 120 |
|
| 121 |
-
# Run gradient ascent
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
# Convert numpy arrays to PIL images
|
| 125 |
dream_pil_image = array_to_img(deprocess_inception_image(image_array))
|
|
|
|
| 118 |
selected_layers = [f'mixed{i}' for i, checkbox in enumerate(layer_checkboxes, start=1) if checkbox]
|
| 119 |
dream_model = deep_dream_model(inception, selected_layers)
|
| 120 |
|
| 121 |
+
# Run gradient ascent with progress bar
|
| 122 |
+
progress_bar = st.progress(0.0) # Initialize progress bar
|
| 123 |
+
for epoch in range(epochs):
|
| 124 |
+
for step in range(steps_per_epoch):
|
| 125 |
+
_, grads = get_loss_and_gradient(dream_model, preprocessed_image, total_variation_weight)
|
| 126 |
+
preprocessed_image = preprocessed_image + grads * weight
|
| 127 |
+
preprocessed_image = tf.clip_by_value(preprocessed_image, -1.0, 1.0)
|
| 128 |
+
|
| 129 |
+
# Update progress bar
|
| 130 |
+
progress_value = ((epoch * steps_per_epoch) + step) / (epochs * steps_per_epoch)
|
| 131 |
+
progress_bar.progress(progress_value)
|
| 132 |
|
| 133 |
# Convert numpy arrays to PIL images
|
| 134 |
dream_pil_image = array_to_img(deprocess_inception_image(image_array))
|