Wendy-Fly commited on
Commit
1a388f5
·
verified ·
1 Parent(s): 22ffc93

Upload test_mgie.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. test_mgie.py +3 -2
test_mgie.py CHANGED
@@ -114,6 +114,7 @@ for i in tqdm(range(1)):
114
 
115
  img = image_processor.preprocess(img, return_tensors='pt')['pixel_values'][0]
116
  xmb = data[i]["content"][1]["text"]
 
117
  txt = "what will this image be like if '%s'"%(txt)
118
  txt = txt+'\n'+DEFAULT_IM_START_TOKEN+DEFAULT_IMAGE_PATCH_TOKEN*image_token_len+DEFAULT_IM_END_TOKEN
119
  conv = conv_templates['vicuna_v1'].copy()
@@ -140,9 +141,9 @@ for i in tqdm(range(1)):
140
  res.save(save_img_path)
141
  token_indices = T.arange(1, len(xmb) + 1)
142
 
143
- token_indices = get_indices_to_alter(pipe, xmb) if token_indices is None else token_indices
144
  img = vis_utils.show_cross_attention(attention_store=controller,
145
- prompt=xmb,
146
  tokenizer=tokenizer,
147
  res=16,
148
  from_where=("up", "down", "mid"),
 
114
 
115
  img = image_processor.preprocess(img, return_tensors='pt')['pixel_values'][0]
116
  xmb = data[i]["content"][1]["text"]
117
+ xb = data[i]["content"][1]["text"]
118
  txt = "what will this image be like if '%s'"%(txt)
119
  txt = txt+'\n'+DEFAULT_IM_START_TOKEN+DEFAULT_IMAGE_PATCH_TOKEN*image_token_len+DEFAULT_IM_END_TOKEN
120
  conv = conv_templates['vicuna_v1'].copy()
 
141
  res.save(save_img_path)
142
  token_indices = T.arange(1, len(xmb) + 1)
143
 
144
+ token_indices = get_indices_to_alter(pipe, xb) if token_indices is None else token_indices
145
  img = vis_utils.show_cross_attention(attention_store=controller,
146
+ prompt=xb,
147
  tokenizer=tokenizer,
148
  res=16,
149
  from_where=("up", "down", "mid"),