Spaces:
Sleeping
Sleeping
Update gligen/ldm/models/diffusion/plms.py
Browse files
gligen/ldm/models/diffusion/plms.py
CHANGED
@@ -3,7 +3,7 @@ import numpy as np
|
|
3 |
from tqdm import tqdm
|
4 |
from functools import partial
|
5 |
from copy import deepcopy
|
6 |
-
|
7 |
from ldm.modules.diffusionmodules.util import make_ddim_sampling_parameters, make_ddim_timesteps, noise_like
|
8 |
import math
|
9 |
from ldm.models.diffusion.loss import caculate_loss_att_fixed_cnt, caculate_loss_self_att, caculate_loss_LoCo,caculate_loss_LAC, caculate_loss_LoCo_V2
|
@@ -82,11 +82,6 @@ class PLMSSampler(object):
|
|
82 |
if self.alpha_generator_func != None:
|
83 |
alphas = self.alpha_generator_func(len(time_range))
|
84 |
|
85 |
-
# 新加的scheduler
|
86 |
-
noise_scheduler = LMSDiscreteScheduler(beta_start=0.00085, beta_end=0.012,
|
87 |
-
beta_schedule="scaled_linear", num_train_timesteps=1000)
|
88 |
-
noise_scheduler.set_timesteps(50)
|
89 |
-
|
90 |
for i, step in enumerate(time_range):
|
91 |
|
92 |
# set alpha and restore first conv layer
|
@@ -109,7 +104,7 @@ class PLMSSampler(object):
|
|
109 |
if loss_type !=None and loss_type!='standard':
|
110 |
if input['object_position'] != []:
|
111 |
|
112 |
-
|
113 |
x = self.update_loss_LoCo( input,i, index, ts, time_factor = time_factor)
|
114 |
|
115 |
input["x"] = x
|
@@ -122,7 +117,6 @@ class PLMSSampler(object):
|
|
122 |
return img
|
123 |
|
124 |
|
125 |
-
|
126 |
def update_loss_LoCo(self, input,index1, index, ts, time_factor, type_loss='self_accross'):
|
127 |
|
128 |
# loss_scale = 30
|
|
|
3 |
from tqdm import tqdm
|
4 |
from functools import partial
|
5 |
from copy import deepcopy
|
6 |
+
|
7 |
from ldm.modules.diffusionmodules.util import make_ddim_sampling_parameters, make_ddim_timesteps, noise_like
|
8 |
import math
|
9 |
from ldm.models.diffusion.loss import caculate_loss_att_fixed_cnt, caculate_loss_self_att, caculate_loss_LoCo,caculate_loss_LAC, caculate_loss_LoCo_V2
|
|
|
82 |
if self.alpha_generator_func != None:
|
83 |
alphas = self.alpha_generator_func(len(time_range))
|
84 |
|
|
|
|
|
|
|
|
|
|
|
85 |
for i, step in enumerate(time_range):
|
86 |
|
87 |
# set alpha and restore first conv layer
|
|
|
104 |
if loss_type !=None and loss_type!='standard':
|
105 |
if input['object_position'] != []:
|
106 |
|
107 |
+
|
108 |
x = self.update_loss_LoCo( input,i, index, ts, time_factor = time_factor)
|
109 |
|
110 |
input["x"] = x
|
|
|
117 |
return img
|
118 |
|
119 |
|
|
|
120 |
def update_loss_LoCo(self, input,index1, index, ts, time_factor, type_loss='self_accross'):
|
121 |
|
122 |
# loss_scale = 30
|