Spaces:
Runtime error
Runtime error
Commit
·
c19b710
1
Parent(s):
fd9afda
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,7 +18,7 @@ class Demo:
|
|
| 18 |
|
| 19 |
self.training = False
|
| 20 |
|
| 21 |
-
|
| 22 |
|
| 23 |
with gr.Blocks() as demo:
|
| 24 |
self.layout()
|
|
@@ -155,7 +155,10 @@ class Demo:
|
|
| 155 |
# self.diffuser = StableDiffuser(scheduler='DDIM', seed=42).to('cuda').eval().half()
|
| 156 |
if self.training:
|
| 157 |
return [gr.update(interactive=True, value='Train'), gr.update(value='Someone else is training... Try again soon'), None, gr.update()]
|
| 158 |
-
|
|
|
|
|
|
|
|
|
|
| 159 |
if train_method == 'ESD-x':
|
| 160 |
|
| 161 |
modules = ".*attn2$"
|
|
@@ -186,12 +189,13 @@ class Demo:
|
|
| 186 |
model_map['Custom'] = save_path
|
| 187 |
|
| 188 |
# del self.diffuser
|
| 189 |
-
|
|
|
|
| 190 |
return [gr.update(interactive=True, value='Train'), gr.update(value='Done Training'), save_path, gr.Dropdown.update(choices=list(model_map.keys()), value='Custom')]
|
| 191 |
|
| 192 |
|
| 193 |
def inference(self, prompt, seed, model_name, pbar = gr.Progress(track_tqdm=True)):
|
| 194 |
-
|
| 195 |
self.diffuser._seed = seed or 42
|
| 196 |
|
| 197 |
model_path = model_map[model_name]
|
|
@@ -222,7 +226,7 @@ class Demo:
|
|
| 222 |
|
| 223 |
edited_image = images[0][0]
|
| 224 |
|
| 225 |
-
del self.finetuner
|
| 226 |
torch.cuda.empty_cache()
|
| 227 |
|
| 228 |
return edited_image, orig_image
|
|
|
|
| 18 |
|
| 19 |
self.training = False
|
| 20 |
|
| 21 |
+
self.diffuser = StableDiffuser(scheduler='DDIM', seed=42).to('cuda').eval().half()
|
| 22 |
|
| 23 |
with gr.Blocks() as demo:
|
| 24 |
self.layout()
|
|
|
|
| 155 |
# self.diffuser = StableDiffuser(scheduler='DDIM', seed=42).to('cuda').eval().half()
|
| 156 |
if self.training:
|
| 157 |
return [gr.update(interactive=True, value='Train'), gr.update(value='Someone else is training... Try again soon'), None, gr.update()]
|
| 158 |
+
# clear the diffusers
|
| 159 |
+
del self.diffuser
|
| 160 |
+
torch.cuda.empty_cache()
|
| 161 |
+
|
| 162 |
if train_method == 'ESD-x':
|
| 163 |
|
| 164 |
modules = ".*attn2$"
|
|
|
|
| 189 |
model_map['Custom'] = save_path
|
| 190 |
|
| 191 |
# del self.diffuser
|
| 192 |
+
torch.cuda.empty_cache()
|
| 193 |
+
self.diffuser = StableDiffuser(scheduler='DDIM', seed=42).to('cuda').eval().half()
|
| 194 |
return [gr.update(interactive=True, value='Train'), gr.update(value='Done Training'), save_path, gr.Dropdown.update(choices=list(model_map.keys()), value='Custom')]
|
| 195 |
|
| 196 |
|
| 197 |
def inference(self, prompt, seed, model_name, pbar = gr.Progress(track_tqdm=True)):
|
| 198 |
+
|
| 199 |
self.diffuser._seed = seed or 42
|
| 200 |
|
| 201 |
model_path = model_map[model_name]
|
|
|
|
| 226 |
|
| 227 |
edited_image = images[0][0]
|
| 228 |
|
| 229 |
+
del self.finetuner
|
| 230 |
torch.cuda.empty_cache()
|
| 231 |
|
| 232 |
return edited_image, orig_image
|