Form Recognizer Studio 可以选择共享和导入自定义创建的模型。它为模型生成一个 token ,可以共享该 token 并将其导入到另一个帐户中。
我想使用 Python 脚本获取此 token 。有什么办法可以用Python来完成这个任务吗? 谢谢!
我尝试使用下面的代码
from azure.core.credentials import AzureKeyCredential
from azure.ai.formrecognizer import FormTrainingClient
client = FormTrainingClient(endpoint, AzureKeyCredential(key))
target = client.get_copy_authorization(resource_id="", resource_region="eastus")
使用此代码,我可以获得 accessToken,但这与资源组相关联。我想获得 token 来共享自定义构建的表单识别器模型。
最佳答案
According to the solution in this github issue, Refer here:- TypeError: in method 'IndexFlat_add', argument 3 of type 'float const *' · Issue #461 · facebookresearch/faiss · GitHub Make sure the generated vector types or array is of numpy.float32
代码 1:-
import numpy as np
d = 128
n = 10000
xb = np.random.rand(n, d).astype(np.float32)
vector = [0.5] * d
vector = np.array(vector).astype(np.float32)
distances = np.linalg.norm(xb - vector, axis=1)
k = 5
indices = np.argsort(distances)[:k]
print("Distances:", distances[indices])
print("Indices:", indices)
上面的代码带有 faiss 库。
import numpy as np
import faiss
d = 128
n = 10000
index = faiss.IndexFlatL2(d)
xb = np.random.rand(n, d).astype(np.float32)
index.add(xb)
vector = [0.5] * d
vector = np.array(vector).astype(np.float32)
k = 5
distances, indices = index.search(np.array([vector]), k)
print("Distances:", distances)
print("Indices:", indices)
输出:-
代码 2:-
import numpy as np
d = 128
n = 10000
x = np.random.rand(n, d).astype(np.float32)
print (x)
输出:-
关于python - 获取 token 以使用 Python 将表单识别器自定义模型从一个帐户共享到另一个帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76032069/