FlameF0X commited on
Commit
dfcb3c1
·
verified ·
1 Parent(s): 66773c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -121,13 +121,13 @@ def run_autoencoder_sandbox(
121
  progress(0, desc="Preprocessing image...")
122
  img_tensor, original_resized = preprocess_image(input_image, resolution)
123
 
124
- # Flatten dimensions
125
  input_dim = 3 * resolution * resolution
126
- flat_clean = img_tensor.view(1, -1)
127
 
128
  # 2. Setup Noise (for Denoising mode)
129
  noisy_img_tensor = add_gaussian_noise(img_tensor, noise_factor)
130
- flat_input = noisy_img_tensor.view(1, -1)
131
 
132
  # Pre-render the noisy input for user preview
133
  noisy_preview = postprocess_tensor(noisy_img_tensor, resolution)
@@ -177,8 +177,8 @@ def run_autoencoder_sandbox(
177
  if epoch % update_every == 0 or epoch == epochs - 1:
178
  progress((epoch + 1) / epochs, desc=f"Epoch {epoch+1}/{epochs} | Loss: {loss.item():.5f}")
179
 
180
- # Format reconstructed image back to normal shape
181
- reconstructed_tensor = reconstructed.view(1, 3, resolution, resolution)
182
  reconstructed_pil = postprocess_tensor(reconstructed_tensor, resolution)
183
 
184
  # Generate loss graph
 
121
  progress(0, desc="Preprocessing image...")
122
  img_tensor, original_resized = preprocess_image(input_image, resolution)
123
 
124
+ # Flatten dimensions using .reshape() instead of .view() to avoid layout conflicts
125
  input_dim = 3 * resolution * resolution
126
+ flat_clean = img_tensor.reshape(1, -1)
127
 
128
  # 2. Setup Noise (for Denoising mode)
129
  noisy_img_tensor = add_gaussian_noise(img_tensor, noise_factor)
130
+ flat_input = noisy_img_tensor.reshape(1, -1)
131
 
132
  # Pre-render the noisy input for user preview
133
  noisy_preview = postprocess_tensor(noisy_img_tensor, resolution)
 
177
  if epoch % update_every == 0 or epoch == epochs - 1:
178
  progress((epoch + 1) / epochs, desc=f"Epoch {epoch+1}/{epochs} | Loss: {loss.item():.5f}")
179
 
180
+ # Format reconstructed image back to normal shape using .reshape()
181
+ reconstructed_tensor = reconstructed.reshape(1, 3, resolution, resolution)
182
  reconstructed_pil = postprocess_tensor(reconstructed_tensor, resolution)
183
 
184
  # Generate loss graph