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): """ 向日志...
参数: x (list): 输入特征图列表。 返回: y (tensor): 包含边界框和类别概率的输出。 """ shape = x[0].shape # 获取输入形状 BCHW for i in range(self.nl): # 将两个卷积层的输出进行拼接 x[i] = torch.cat((self.cv2[i](x[i]), self.cv3[i](x[i])), 1) # 如果处于训练状态,直...
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...