srinivasbilla commited on
Commit
56507f1
Β·
verified Β·
1 Parent(s): 533dbf3

remove api key

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -89,20 +89,19 @@ def load_examples(n: int = 3):
89
  static_examples = load_examples()
90
 
91
  # ───────── backend for user Run ─────────
92
- def run_mapper(prompt: str, img_url: str, api_key: str):
93
- new_client = JinaV4SimilarityMapper(client_type="web")
 
94
  if not img_url:
95
  raise gr.Error("Please provide an image URL.")
96
  if not prompt:
97
  raise gr.Error("Please provide a prompt.")
98
- if not api_key:
99
- raise gr.Error("Please provide a valid API key.")
100
  try:
101
  r = requests.get(img_url, stream=True, timeout=10); r.raise_for_status()
102
  img = Image.open(io.BytesIO(r.content)).convert("RGB")
103
  except Exception as e:
104
  raise gr.Error(f"Image load failed: {e}")
105
- new_client.model.set_api_key(api_key)
106
  img_proc, *_ = new_client.process_image(img_url)
107
  toks, maps = new_client.get_token_similarity_maps(prompt, img_proc)
108
  if not toks:
@@ -132,7 +131,6 @@ with gr.Blocks(css=css) as demo:
132
  # User input
133
  prompt_in = gr.Textbox(label="Prompt", placeholder="Describe what to query…")
134
  url_in = gr.Textbox(label="Image URL", placeholder="https://example.com/image.jpg")
135
- api_key_in = gr.Textbox(label="API Key", placeholder="Enter your Jina API key here")
136
  run_btn = gr.Button("Run", elem_id="run-btn")
137
 
138
  # Output area
@@ -143,7 +141,7 @@ with gr.Blocks(css=css) as demo:
143
  img_out = gr.Image(label="Image + Heatmap", visible=False)
144
 
145
  run_btn.click(run_mapper,
146
- [prompt_in, url_in, api_key_in],
147
  [token_sel, maps_st, img_st, img_out, info_md, prompt_in, url_in])
148
 
149
  (token_sel.select if hasattr(token_sel,"select") else token_sel.change)(
 
89
  static_examples = load_examples()
90
 
91
  # ───────── backend for user Run ─────────
92
+ def run_mapper(prompt: str, img_url: str):
93
+ # new_client = JinaV4SimilarityMapper(client_type="web")
94
+ new_client = MAPPER
95
  if not img_url:
96
  raise gr.Error("Please provide an image URL.")
97
  if not prompt:
98
  raise gr.Error("Please provide a prompt.")
 
 
99
  try:
100
  r = requests.get(img_url, stream=True, timeout=10); r.raise_for_status()
101
  img = Image.open(io.BytesIO(r.content)).convert("RGB")
102
  except Exception as e:
103
  raise gr.Error(f"Image load failed: {e}")
104
+ # new_client.model.set_api_key(api_key)
105
  img_proc, *_ = new_client.process_image(img_url)
106
  toks, maps = new_client.get_token_similarity_maps(prompt, img_proc)
107
  if not toks:
 
131
  # User input
132
  prompt_in = gr.Textbox(label="Prompt", placeholder="Describe what to query…")
133
  url_in = gr.Textbox(label="Image URL", placeholder="https://example.com/image.jpg")
 
134
  run_btn = gr.Button("Run", elem_id="run-btn")
135
 
136
  # Output area
 
141
  img_out = gr.Image(label="Image + Heatmap", visible=False)
142
 
143
  run_btn.click(run_mapper,
144
+ [prompt_in, url_in],
145
  [token_sel, maps_st, img_st, img_out, info_md, prompt_in, url_in])
146
 
147
  (token_sel.select if hasattr(token_sel,"select") else token_sel.change)(