Spaces:
Sleeping
Sleeping
oyly
commited on
Commit
·
0123c32
1
Parent(s):
66cc858
offload t5 and clip
Browse files
app.py
CHANGED
|
@@ -196,6 +196,9 @@ class FluxEditor_lore_demo:
|
|
| 196 |
t0 = time.perf_counter()
|
| 197 |
print(f'optimizing & editing noise, {target_prompt} with seed {seed}, noise_scale {noise_scale}, training_epochs {training_epochs}')
|
| 198 |
self.model.to(self.device)
|
|
|
|
|
|
|
|
|
|
| 199 |
if training_epochs != 0:
|
| 200 |
torch.set_grad_enabled(True)
|
| 201 |
inp_optim["img"] = self.z0
|
|
@@ -243,6 +246,8 @@ class FluxEditor_lore_demo:
|
|
| 243 |
Image.fromarray(binary_mask, mode="L").save(output_path.replace(target_object,f'{target_object}_mask'))
|
| 244 |
t1 = time.perf_counter()
|
| 245 |
print(f"Done in {t1 - t0:.1f}s.", f'Saving {output_path} .' if self.save else 'No saving files.')
|
|
|
|
|
|
|
| 246 |
|
| 247 |
return img
|
| 248 |
|
|
|
|
| 196 |
t0 = time.perf_counter()
|
| 197 |
print(f'optimizing & editing noise, {target_prompt} with seed {seed}, noise_scale {noise_scale}, training_epochs {training_epochs}')
|
| 198 |
self.model.to(self.device)
|
| 199 |
+
self.t5.to('cpu')
|
| 200 |
+
self.clip.to('cpu')
|
| 201 |
+
torch.cuda.empty_cache()
|
| 202 |
if training_epochs != 0:
|
| 203 |
torch.set_grad_enabled(True)
|
| 204 |
inp_optim["img"] = self.z0
|
|
|
|
| 246 |
Image.fromarray(binary_mask, mode="L").save(output_path.replace(target_object,f'{target_object}_mask'))
|
| 247 |
t1 = time.perf_counter()
|
| 248 |
print(f"Done in {t1 - t0:.1f}s.", f'Saving {output_path} .' if self.save else 'No saving files.')
|
| 249 |
+
self.t5.to(self.device)
|
| 250 |
+
self.clip.to(self.device)
|
| 251 |
|
| 252 |
return img
|
| 253 |
|