songweig commited on
Commit
ff191d6
1 Parent(s): 2793b63
Files changed (2) hide show
  1. app.py +4 -4
  2. utils/attention_utils.py +1 -0
app.py CHANGED
@@ -115,7 +115,7 @@ def main():
115
  model.remove_tokenmap_hooks()
116
  model.register_tokenmap_hooks()
117
  else:
118
- model.reset_attention_maps()
119
  model.remove_tokenmap_hooks()
120
  plain_img = model.sample([base_text_prompt], negative_prompt=[negative_text],
121
  height=height, width=width, num_inference_steps=steps,
@@ -162,7 +162,7 @@ def main():
162
  <p> UMD, Adobe, CMU <p/>
163
  <p> ICCV, 2023 <p/>
164
  <p> <a href="https://huggingface.co/spaces/songweig/rich-text-to-image?duplicate=true"><img src="https://bit.ly/3gLdBN6" style="display:inline;"alt="Duplicate Space"></a> | <a href="https://rich-text-to-image.github.io">[Website]</a> | <a href="https://github.com/SongweiGe/rich-text-to-image">[Code]</a> | <a href="https://arxiv.org/abs/2304.06720">[Paper]</a><p/>
165
- <p> Our method is now upgraded to use Stable Diffusion XL. For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings.""")
166
  with gr.Row():
167
  with gr.Column():
168
  rich_text_el = gr.HTML(canvas_html, elem_id="canvas_html")
@@ -258,8 +258,8 @@ def main():
258
  share_button = gr.Button(
259
  "Share to community", elem_id="share-btn")
260
  share_button.click(None, [], [], _js=share_js)
261
- with gr.Row():
262
- gr.Markdown(help_text)
263
 
264
  with gr.Row():
265
  footnote_examples = [
 
115
  model.remove_tokenmap_hooks()
116
  model.register_tokenmap_hooks()
117
  else:
118
+ model.remove_tokenmap_hooks()
119
  model.remove_tokenmap_hooks()
120
  plain_img = model.sample([base_text_prompt], negative_prompt=[negative_text],
121
  height=height, width=width, num_inference_steps=steps,
 
162
  <p> UMD, Adobe, CMU <p/>
163
  <p> ICCV, 2023 <p/>
164
  <p> <a href="https://huggingface.co/spaces/songweig/rich-text-to-image?duplicate=true"><img src="https://bit.ly/3gLdBN6" style="display:inline;"alt="Duplicate Space"></a> | <a href="https://rich-text-to-image.github.io">[Website]</a> | <a href="https://github.com/SongweiGe/rich-text-to-image">[Code]</a> | <a href="https://arxiv.org/abs/2304.06720">[Paper]</a><p/>
165
+ <p> Our method is now using Stable Diffusion XL. For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings.""")
166
  with gr.Row():
167
  with gr.Column():
168
  rich_text_el = gr.HTML(canvas_html, elem_id="canvas_html")
 
258
  share_button = gr.Button(
259
  "Share to community", elem_id="share-btn")
260
  share_button.click(None, [], [], _js=share_js)
261
+ # with gr.Row():
262
+ # gr.Markdown(help_text)
263
 
264
  with gr.Row():
265
  footnote_examples = [
utils/attention_utils.py CHANGED
@@ -665,6 +665,7 @@ def get_token_maps(selfattn_maps, crossattn_maps, n_maps, save_dir, width, heigh
665
  cross_attn_maps_1024).mean(0).cpu().numpy()
666
  normalized_span_maps = []
667
  for token_ids in obj_tokens:
 
668
  span_token_maps = cross_attn_maps_1024[:, :, token_ids.numpy()]
669
  normalized_span_map = np.zeros_like(span_token_maps)
670
  for i in range(span_token_maps.shape[-1]):
 
665
  cross_attn_maps_1024).mean(0).cpu().numpy()
666
  normalized_span_maps = []
667
  for token_ids in obj_tokens:
668
+ token_ids = [token_id for token_id in token_ids if token_id < 77]
669
  span_token_maps = cross_attn_maps_1024[:, :, token_ids.numpy()]
670
  normalized_span_map = np.zeros_like(span_token_maps)
671
  for i in range(span_token_maps.shape[-1]):