From a043540cbf76bf03fea480e9fed638f8d8e40bf8 Mon Sep 17 00:00:00 2001 From: satori Date: Mon, 11 Nov 2024 18:01:52 +0800 Subject: [PATCH] DEBUG --- demo.py | 3 --- routers/img.py | 4 ++-- routers/reverse.py | 12 ++++++------ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/demo.py b/demo.py index 0dd91bf..6bbef4c 100755 --- a/demo.py +++ b/demo.py @@ -33,9 +33,6 @@ with torch.no_grad(): for x in output: print(x.shape) -# 输出2048维向量 -# print(output[0]) - ''' from towhee import pipe, ops, DataCollection diff --git a/routers/img.py b/routers/img.py index 58ad8bf..718c143 100644 --- a/routers/img.py +++ b/routers/img.py @@ -60,7 +60,7 @@ def get_image_type_thumbnail(type:str, id:str, version:str, n:int, w:int, ext:st if img is None: print('图片不存在:', count) return Response('图片不存在', status_code=404) - url = img[0] + url = img['image'] elif type == 'url': id = unquote(id, 'utf-8') id = id.replace(' ','+') @@ -72,7 +72,7 @@ def get_image_type_thumbnail(type:str, id:str, version:str, n:int, w:int, ext:st if user is None: print('用户不存在:', count) return Response('用户不存在', status_code=404) - url = user[0] + url = user['avatar'] else: print('图片类型不存在:', type) return Response('图片类型不存在', status_code=404) diff --git a/routers/reverse.py b/routers/reverse.py index 2dcbeec..2c04fec 100644 --- a/routers/reverse.py +++ b/routers/reverse.py @@ -47,11 +47,11 @@ async def rewrite_image(image_id: int): if img is None: print('mysql中原始图片不存在:', image_id) return Response('图片不存在', status_code=404) - img_path = os.path.join(UPLOAD_PATH, os.path.basename(img[0])) + img_path = os.path.join(UPLOAD_PATH, os.path.basename(img['content'])) print('img_path', img_path) - image = download_image(img[0]) + image = download_image(img['content']) if image is None: - print('图片下载失败:', img[0]) + print('图片下载失败:', img['content']) return Response('图片下载失败', status_code=404) image.save(img_path, 'png', save_all=True) with Image.open(img_path) as imgx: @@ -78,10 +78,10 @@ async def similar_images(image_id: int, page: int = 1, pageSize: int = 20): if img is None: print('mysql 中图片不存在:', image_id) return Response('图片不存在', status_code=404) - img_path = os.path.join(UPLOAD_PATH, os.path.basename(img[0])) - image = download_image(img[0]) + img_path = os.path.join(UPLOAD_PATH, os.path.basename(img['content'])) + image = download_image(img['content']) if image is None: - print('图片下载失败:', img[0]) + print('图片下载失败:', img['content']) return Response('图片下载失败', status_code=404) image.save(img_path, 'png', save_all=True) with Image.open(img_path) as imgx: