code: from typing import Any, List, Optional, Tuple
  
  import gradio as gr
  import lancedb
  from transformers import CLIPModel, CLIPTokenizerFast
  
  from homematch.config import DATA_DIR, MODEL_ID, TABLE_NAME
  from homematch.data.types import ImageData
  
  DEVICE: str = "cpu"
  model: CLIPModel = CLIPModel.from_pretrained(MODEL_ID).to(DEVICE)
  tokenizer: CLIPTokenizerFast = CLIPTokenizerFast.from_pretrained(MODEL_ID)
  
  uri: str = str(DATA_DIR) + "/.lancedb/"
  db = lancedb.connect(uri)
  table = db[TABLE_NAME]
  
  
  def embed_func(query: str) -> Any:
      inputs = tokenizer([query], padding=True, return_tensors="pt").to(DEVICE)
      text_features = model.get_text_features(**inputs)
      return text_features.detach().numpy()[0]
  
  
  def find_images(query: str) -> List[Tuple[Any, str]]:
      emb = embed_func(query)
      rs = table.search(emb).limit(9).to_pydantic(ImageData)
      return [(image.load_image(), image.text_description) for image in rs]
  
  
  def update_description(image_info: Optional[Tuple[Any, str]]) -> str:
      print(image_info)
      print("asd")
      if image_info is None or image_info[0] is None:
          return "Select an image to see its description"
      else:
          _, description = image_info
          return description
  
  
  with gr.Blocks() as demo:
      with gr.Row():
          vector_query: gr.Textbox = gr.Textbox(
              value="A modern building with 2 bathrooms and 3 bedrooms", show_label=False
          )
          b1: gr.Button = gr.Button("Submit")
      with gr.Row():
          gallery: gr.Gallery = gr.Gallery(
              label="Found images",
              show_label=False,
              elem_id="gallery",
              columns=3,
              rows=3,
              object_fit="contain",
              height="auto",
          )
  
      b1.click(find_images, inputs=vector_query, outputs=gallery)
  
  demo.launch(server_name="127.0.0.1", inline=False)
  
apis: lancedb.connect
extract_api: [((358, 401), 'transformers.CLIPTokenizerFast.from_pretrained', 'CLIPTokenizerFast.from_pretrained', (['MODEL_ID'], {}), '(MODEL_ID)\n', (391, 401), False, 'from transformers import CLIPModel, CLIPTokenizerFast\n'), ((448, 468), 'lancedb.connect', 'lancedb.connect', (['uri'], {}), '(uri)\n', (463, 468), False, 'import lancedb\n'), ((1222, 1233), 'gradio.Blocks', 'gr.Blocks', ([], {}), '()\n', (1231, 1233), True, 'import gradio as gr\n'), ((280, 315), 'transformers.CLIPModel.from_pretrained', 'CLIPModel.from_pretrained', (['MODEL_ID'], {}), '(MODEL_ID)\n', (305, 315), False, 'from transformers import CLIPModel, CLIPTokenizerFast\n'), ((1252, 1260), 'gradio.Row', 'gr.Row', ([], {}), '()\n', (1258, 1260), True, 'import gradio as gr\n'), ((1297, 1388), 'gradio.Textbox', 'gr.Textbox', ([], {'value': '"""A modern building with 2 bathrooms and 3 bedrooms"""', 'show_label': '(False)'}), "(value='A modern building with 2 bathrooms and 3 bedrooms',\n    show_label=False)\n", (1307, 1388), True, 'import gradio as gr\n'), ((1431, 1450), 'gradio.Button', 'gr.Button', (['"""Submit"""'], {}), "('Submit')\n", (1440, 1450), True, 'import gradio as gr\n'), ((1460, 1468), 'gradio.Row', 'gr.Row', ([], {}), '()\n', (1466, 1468), True, 'import gradio as gr\n'), ((1500, 1629), 'gradio.Gallery', 'gr.Gallery', ([], {'label': '"""Found images"""', 'show_label': '(False)', 'elem_id': '"""gallery"""', 'columns': '(3)', 'rows': '(3)', 'object_fit': '"""contain"""', 'height': '"""auto"""'}), "(label='Found images', show_label=False, elem_id='gallery',\n    columns=3, rows=3, object_fit='contain', height='auto')\n", (1510, 1629), True, 'import gradio as gr\n')]