create_table(sim_idx_table_name, schema=get_sim_index_schema(), mode="overwrite") # 创建相似性索引表 def _yield_sim_idx(): """生成包含相似性索引和距离的数据框。""" for i in tqdm(range(len(embeddings))): sim_idx = self.table.search(embeddings[i]).limit(top_k).to_pandas()....
create_table(sim_idx_table_name, schema=get_sim_index_schema(), mode="overwrite") # 生成相似性索引 for i in tqdm(range(len(embeddings))): sim_idx = self.table.search(embeddings[i]).limit(top_k).to_pandas().query(f"_distance <= {max_dist}") yield [ { "idx": i, "im_file"...
im_files[i]) # 读取图像 if im is None: raise FileNotFoundError(f"未找到图像 {self.im_files[i]}") # 调整图像大小 im = cv2.resize(im, (self.imgsz, self.imgsz), interpolation=cv2.INTER_LINEAR) return im def __getitem__(self, index): """返回给定索引的图像和标签信息。""" ...
"" for i in tqdm(range(len(dataset))): self.progress = float(i + 1) / len(dataset) batch = dataset[i] batch["vector"] = model.embed(batch["im_file"], verbose=False)[0].detach().tolist() # 计算嵌入向量 yield [batch] def query(self, imgs: Union[str, np.ndarray, List[...
to_csv(csv_file_path, index=False, header=True) self.data = pd.DataFrame(columns=columns) except (FileNotFoundError, pd.errors.EmptyDataError): self.data = pd.DataFrame(columns=columns) def add_log_entry(self, file_path, recognition_result, position, confidence, time_spent): """ 向日志...
asarray([[x[i], y[i]] for i in range(len(x)) if cost_matrix[x[i], y[i]] <= thresh]) if len(matches) == 0: unmatched_a = list(np.arange(cost_matrix.shape[0])) unmatched_b = list(np.arange(cost_matrix.shape[1])) else: unmatched_a = list(set(np.arange(cost_matrix...
asarray([[x[i], y[i]] for i in range(len(x)) if cost_matrix[x[i], y[i]] <= thresh]) if len(matches) == 0: unmatched_a = list(np.arange(cost_matrix.shape[0])) unmatched_b = list(np.arange(cost_matrix.shape[1])) else: unmatched_a = list(set(np.arange(cost_matrix...