使用 5001 的向量服务

This commit is contained in:
2023-11-17 01:12:22 +08:00
parent aa05cd952f
commit 9cd4f917cc
2 changed files with 1 additions and 4 deletions

View File

@@ -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')) # 將結果發送給客戶端