unnati026 commited on
Commit
d84c1d8
·
1 Parent(s): c146a72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
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
- image_array = run_gradient_ascent(dream_model, preprocessed_image, epochs=epochs, steps_per_epoch=steps_per_epoch, weight=weight)
 
 
 
 
 
 
 
 
 
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))