pepeline_extract_subimg.py: extract subimg
This commit is contained in:
@ -404,8 +404,8 @@ def stdfeat_infer(imgPath, featPath, bcdSet=None):
|
||||
feature_ft16 /= np.linalg.norm(feature_ft16, axis=1)[:, None]
|
||||
|
||||
# uint8, 两种策略,1) 精度损失小, 2) 计算复杂度小
|
||||
# stdfeat_uint8, _ = ft16_to_uint8(feature_ft16)
|
||||
stdfeat_uint8 = (feature_ft16*128).astype(np.int8)
|
||||
# feature_uint8, _ = ft16_to_uint8(feature_ft16)
|
||||
feature_uint8 = (feature_ft16*128).astype(np.int8)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error accured at: {filename}, with Exception is: {e}")
|
||||
@ -414,32 +414,15 @@ def stdfeat_infer(imgPath, featPath, bcdSet=None):
|
||||
##================== float32
|
||||
stdbDict["barcode"] = barcode
|
||||
stdbDict["imgpaths"] = imgpaths
|
||||
stdbDict["feats"] = feature
|
||||
stdbDict["feats_ft32"] = feature
|
||||
stdbDict["feats_ft16"] = feature_ft16
|
||||
stdbDict["feats_uint8"] = feature_uint8
|
||||
|
||||
# pkpath = os.path.join(featPath, f"{barcode}.pickle")
|
||||
with open(pkpath, 'wb') as f:
|
||||
pickle.dump(stdbDict, f)
|
||||
|
||||
stdBarcodeDict[barcode] = feature
|
||||
|
||||
|
||||
##================== float16
|
||||
# stdbDict_ft16["barcode"] = barcode
|
||||
# stdbDict_ft16["imgpaths"] = imgpaths
|
||||
# stdbDict_ft16["feats"] = feature_ft16
|
||||
# pkpath_ft16 = os.path.join(featPath, f"{barcode}_ft16.pickle")
|
||||
# with open(pkpath_ft16, 'wb') as f:
|
||||
# pickle.dump(stdbDict_ft16, f)
|
||||
# stdBarcodeDict_ft16[barcode] = pkpath_ft16
|
||||
|
||||
|
||||
|
||||
##================== uint8
|
||||
# stdbDict_uint8["barcode"] = barcode
|
||||
# stdbDict_uint8["imgpaths"] = imgpaths
|
||||
# stdbDict_uint8["feats"] = stdfeat_uint8
|
||||
# pkpath_uint8 = os.path.join(featPath, f"{barcode}_uint8.pickle")
|
||||
# with open(pkpath_uint8, 'wb') as f:
|
||||
# pickle.dump(stdbDict_uint8, f)
|
||||
stdBarcodeDict_ft16[barcode] = feature_ft16
|
||||
|
||||
t2 = time.time()
|
||||
print(f"Barcode: {barcode}, need time: {t2-t1:.1f} secs")
|
||||
@ -813,7 +796,7 @@ def main_std():
|
||||
|
||||
get_std_barcodeDict(std_sample_path, std_barcode_path)
|
||||
|
||||
# stdfeat_infer(std_barcode_path, std_feature_path, bcdSet=None)
|
||||
stdfeat_infer(std_barcode_path, std_feature_path, bcdSet=None)
|
||||
|
||||
# fileList = []
|
||||
# for filename in os.listdir(std_barcode_path):
|
||||
@ -829,7 +812,7 @@ if __name__ == '__main__':
|
||||
# main()
|
||||
|
||||
|
||||
# main_std()
|
||||
main_std()
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user