DEBUG
This commit is contained in:
		@@ -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:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user