uruguayai commited on
Commit
6f411d1
·
verified ·
1 Parent(s): 649234d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -0
app.py CHANGED
@@ -121,8 +121,12 @@ def train_step(state, batch, rng):
121
  timestep_rng, (batch_size,), 0, pipeline.scheduler.config.num_train_timesteps
122
  )
123
 
 
 
 
124
  # Add noise to images using the scheduler
125
  noisy_images = pipeline.scheduler.add_noise(
 
126
  original_samples=pixel_values,
127
  noise=noise,
128
  timesteps=timesteps
@@ -169,6 +173,7 @@ for epoch in range(num_epochs):
169
  avg_loss = epoch_loss / num_batches
170
  print(f"Epoch {epoch+1}/{num_epochs}, Average Loss: {avg_loss}")
171
 
 
172
  # Save the fine-tuned model
173
  output_dir = "/tmp/montevideo_fine_tuned_model"
174
  os.makedirs(output_dir, exist_ok=True)
 
121
  timestep_rng, (batch_size,), 0, pipeline.scheduler.config.num_train_timesteps
122
  )
123
 
124
+ # Create scheduler state
125
+ scheduler_state = pipeline.scheduler.create_state()
126
+
127
  # Add noise to images using the scheduler
128
  noisy_images = pipeline.scheduler.add_noise(
129
+ scheduler_state,
130
  original_samples=pixel_values,
131
  noise=noise,
132
  timesteps=timesteps
 
173
  avg_loss = epoch_loss / num_batches
174
  print(f"Epoch {epoch+1}/{num_epochs}, Average Loss: {avg_loss}")
175
 
176
+
177
  # Save the fine-tuned model
178
  output_dir = "/tmp/montevideo_fine_tuned_model"
179
  os.makedirs(output_dir, exist_ok=True)