huy-ha commited on
Commit
504c2ad
·
1 Parent(s): a9568f2

set max labels length

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -39,6 +39,8 @@ def generate_relevancy(
39
  img: np.array, labels: str, prompt: str, saliency_config: str, subtract_mean: bool
40
  ):
41
  labels = labels.split(",")
 
 
42
  prompts = [prompt]
43
  img = np.asarray(Image.fromarray(img).resize((244 * 4, 244 * 4)))
44
  assert img.dtype == np.uint8
@@ -87,8 +89,10 @@ This relevancy extractor builds heavily on [Chefer et al.'s codebase](https://gi
87
  cache_examples=True,
88
  inputs=[
89
  gr.Image(type="numpy", label="Image"),
90
- gr.Textbox(label="Labels (comma separated)"),
91
- gr.Textbox(label="Prompt"),
 
 
92
  gr.Dropdown(
93
  value="ours",
94
  choices=["ours", "ours_fast", "chefer_et_al"],
@@ -128,5 +132,4 @@ This relevancy extractor builds heavily on [Chefer et al.'s codebase](https://gi
128
  ],
129
  ],
130
  )
131
- # iface.launch(share=True)
132
  iface.launch()
 
39
  img: np.array, labels: str, prompt: str, saliency_config: str, subtract_mean: bool
40
  ):
41
  labels = labels.split(",")
42
+ if len(labels) > 32:
43
+ labels = labels[:32]
44
  prompts = [prompt]
45
  img = np.asarray(Image.fromarray(img).resize((244 * 4, 244 * 4)))
46
  assert img.dtype == np.uint8
 
89
  cache_examples=True,
90
  inputs=[
91
  gr.Image(type="numpy", label="Image"),
92
+ gr.Textbox(label="Labels (comma separated without spaces in between)"),
93
+ gr.Textbox(
94
+ label="Prompt. (Make sure to include \{\} in the prompt like examples below)"
95
+ ),
96
  gr.Dropdown(
97
  value="ours",
98
  choices=["ours", "ours_fast", "chefer_et_al"],
 
132
  ],
133
  ],
134
  )
 
135
  iface.launch()