rynmurdock commited on
Commit
a1a9800
1 Parent(s): 29b27a4

lunchbreak add

Browse files
Files changed (1) hide show
  1. app.py +15 -9
app.py CHANGED
@@ -94,8 +94,8 @@ device_map='cuda')
94
 
95
 
96
 
97
- unet = UNet2DConditionModel.from_pretrained('emilianJR/epiCRealism', subfolder='unet',).to(dtype).to('cpu')
98
- text_encoder = CLIPTextModel.from_pretrained('emilianJR/epiCRealism', subfolder='text_encoder',
99
  device_map='cpu').to(dtype)
100
 
101
  adapter = MotionAdapter.from_pretrained("wangfuyun/AnimateLCM")
@@ -114,7 +114,7 @@ pipe.fuse_lora()
114
 
115
  pipe.load_ip_adapter("h94/IP-Adapter", subfolder="models", weight_name="ip-adapter_sd15_vit-G.bin", map_location='cpu')
116
  # This IP adapter improves outputs substantially.
117
- pipe.set_ip_adapter_scale(.8)
118
  pipe.unet.fuse_qkv_projections()
119
  #pipe.enable_free_init(method="gaussian", use_fast_sampling=True)
120
 
@@ -156,11 +156,12 @@ def generate(in_im_embs):
156
 
157
  def get_user_emb(embs, ys):
158
  # handle case where every instance of calibration videos is 'Neither' or 'Like' or 'Dislike'
159
- if len(list(set(ys))) <= 1:
160
- embs.append(.01*torch.randn(1280))
161
- embs.append(.01*torch.randn(1280))
162
- ys.append(0)
163
- ys.append(1)
 
164
 
165
  indices = list(range(len(embs)))
166
  # sample only as many negatives as there are positives
@@ -177,9 +178,14 @@ def get_user_emb(embs, ys):
177
  if len(ys) > len(embs):
178
  ys.pop(-1)
179
 
180
- feature_embs = np.array(torch.stack([embs[i].squeeze().to('cpu') for i in indices]).to('cpu'))
181
  #scaler = preprocessing.StandardScaler().fit(feature_embs)
182
  #feature_embs = scaler.transform(feature_embs)
 
 
 
 
 
183
  chosen_y = np.array([ys[i] for i in indices])
184
 
185
  #lin_class = Ridge(fit_intercept=False).fit(feature_embs, chosen_y)
 
94
 
95
 
96
 
97
+ unet = UNet2DConditionModel.from_pretrained('rynmurdock/Sea_Claws', subfolder='unet',).to(dtype).to('cpu')
98
+ text_encoder = CLIPTextModel.from_pretrained('rynmurdock/Sea_Claws', subfolder='text_encoder',
99
  device_map='cpu').to(dtype)
100
 
101
  adapter = MotionAdapter.from_pretrained("wangfuyun/AnimateLCM")
 
114
 
115
  pipe.load_ip_adapter("h94/IP-Adapter", subfolder="models", weight_name="ip-adapter_sd15_vit-G.bin", map_location='cpu')
116
  # This IP adapter improves outputs substantially.
117
+ pipe.set_ip_adapter_scale(.9)
118
  pipe.unet.fuse_qkv_projections()
119
  #pipe.enable_free_init(method="gaussian", use_fast_sampling=True)
120
 
 
156
 
157
  def get_user_emb(embs, ys):
158
  # handle case where every instance of calibration videos is 'Neither' or 'Like' or 'Dislike'
159
+ if len(list(ys)) <= 7:
160
+ aways = [.01*torch.randn(1280) for i in range(3)]
161
+ embs += aways
162
+ awal = [0 for i in range(3)]
163
+ ys += awal
164
+ print('Fixing only one feedback class available.\n')
165
 
166
  indices = list(range(len(embs)))
167
  # sample only as many negatives as there are positives
 
178
  if len(ys) > len(embs):
179
  ys.pop(-1)
180
 
181
+ feature_embs = torch.stack([embs[i].squeeze().to('cpu') for i in indices]).to('cpu')
182
  #scaler = preprocessing.StandardScaler().fit(feature_embs)
183
  #feature_embs = scaler.transform(feature_embs)
184
+
185
+
186
+ if feature_embs.norm() != 0:
187
+ feature_embs = feature_embs / feature_embs.norm()
188
+
189
  chosen_y = np.array([ys[i] for i in indices])
190
 
191
  #lin_class = Ridge(fit_intercept=False).fit(feature_embs, chosen_y)