From 7d153debdf67e7b8a17f03c2f385ae3980c78da3 Mon Sep 17 00:00:00 2001 From: satori Date: Mon, 11 Nov 2024 17:49:16 +0800 Subject: [PATCH] DEBUG --- routers/reverse.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/routers/reverse.py b/routers/reverse.py index 7759b4c..2dcbeec 100644 --- a/routers/reverse.py +++ b/routers/reverse.py @@ -42,16 +42,16 @@ async def rewrite_image(image_id: int): with pool.connection() as conn: with conn.cursor() as cursor: print('START', image_id, '重建向量') - cursor.execute(f"SELECT * FROM `web_images` WHERE id={image_id}") + cursor.execute(f"SELECT content FROM `web_images` WHERE id={image_id}") img = cursor.fetchone() if img is None: print('mysql中原始图片不存在:', image_id) return Response('图片不存在', status_code=404) - img_path = os.path.join(UPLOAD_PATH, os.path.basename(img['content'])) + img_path = os.path.join(UPLOAD_PATH, os.path.basename(img[0])) print('img_path', img_path) - image = download_image(img['content']) + image = download_image(img[0]) if image is None: - print('图片下载失败:', img['content']) + print('图片下载失败:', img[0]) return Response('图片下载失败', status_code=404) image.save(img_path, 'png', save_all=True) with Image.open(img_path) as imgx: @@ -73,15 +73,15 @@ async def similar_images(image_id: int, page: int = 1, pageSize: int = 20): # 如果没有结果, 则重新生成记录 if len(result) == 0: with conn.cursor() as cursor: - cursor.execute(f"SELECT * FROM `web_images` WHERE id={image_id}") + cursor.execute(f"SELECT content FROM `web_images` WHERE id={image_id}") img = cursor.fetchone() if img is None: print('mysql 中图片不存在:', image_id) return Response('图片不存在', status_code=404) - img_path = os.path.join(UPLOAD_PATH, os.path.basename(img['content'])) - image = download_image(img['content']) + img_path = os.path.join(UPLOAD_PATH, os.path.basename(img[0])) + image = download_image(img[0]) if image is None: - print('图片下载失败:', img['content']) + print('图片下载失败:', img[0]) return Response('图片下载失败', status_code=404) image.save(img_path, 'png', save_all=True) with Image.open(img_path) as imgx: