使用 5001 的向量服务
This commit is contained in:
@@ -114,7 +114,7 @@ func GetNetWorkEmbedding(id int) (embedding []float32) {
|
||||
host := viper.GetString("embedding.host")
|
||||
port := viper.GetInt("embedding.port")
|
||||
httpClient := &http.Client{}
|
||||
request, err := http.NewRequest("PUT", fmt.Sprintf("http://%s:%d/reverse/%d", host, port, id), nil)
|
||||
request, err := http.NewRequest("PUT", fmt.Sprintf("http://%s:%d/api/default/%d", host, port, id), nil)
|
||||
if err != nil {
|
||||
log.Println("请求失败:", err)
|
||||
return
|
||||
|
@@ -46,9 +46,6 @@ class ResNetServer(BaseHTTPRequestHandler):
|
||||
self.end_headers() # 完成服務器響應的標頭
|
||||
content_length = int(self.headers['Content-Length']) # 獲取請求的內容長度
|
||||
body = self.rfile.read(content_length) # 獲取請求的內容
|
||||
#img_path = './data/' + str(uuid.uuid4()) # 生成一個隨機的圖像文件名
|
||||
#with open(img_path, 'wb') as f: # 將二進制圖像文件解碼為圖像數據保存在本地
|
||||
# f.write(body)
|
||||
feat = towhee.blob(body).image_decode().image_embedding.timm(model_name='resnet50').tensor_normalize().to_list()
|
||||
results = json.dumps(feat[0].tolist()) # 將結果轉換為JSON格式
|
||||
self.wfile.write(bytes(results, 'utf-8')) # 將結果發送給客戶端
|
||||
|
Reference in New Issue
Block a user