DEBUG
This commit is contained in:
		
							
								
								
									
										3
									
								
								demo.py
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								demo.py
									
									
									
									
									
								
							@@ -33,9 +33,6 @@ with torch.no_grad():
 | 
				
			|||||||
for x in output:
 | 
					for x in output:
 | 
				
			||||||
    print(x.shape)
 | 
					    print(x.shape)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# 输出2048维向量
 | 
					 | 
				
			||||||
# print(output[0])
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
'''
 | 
					'''
 | 
				
			||||||
from towhee import pipe, ops, DataCollection
 | 
					from towhee import pipe, ops, DataCollection
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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:
 | 
					                if img is None:
 | 
				
			||||||
                    print('图片不存在:', count)
 | 
					                    print('图片不存在:', count)
 | 
				
			||||||
                    return Response('图片不存在', status_code=404)
 | 
					                    return Response('图片不存在', status_code=404)
 | 
				
			||||||
                url = img[0]
 | 
					                url = img['image']
 | 
				
			||||||
            elif type == 'url':
 | 
					            elif type == 'url':
 | 
				
			||||||
                id = unquote(id, 'utf-8')
 | 
					                id = unquote(id, 'utf-8')
 | 
				
			||||||
                id = id.replace(' ','+')
 | 
					                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:
 | 
					                if user is None:
 | 
				
			||||||
                    print('用户不存在:', count)
 | 
					                    print('用户不存在:', count)
 | 
				
			||||||
                    return Response('用户不存在', status_code=404)
 | 
					                    return Response('用户不存在', status_code=404)
 | 
				
			||||||
                url = user[0]
 | 
					                url = user['avatar']
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                print('图片类型不存在:', type)
 | 
					                print('图片类型不存在:', type)
 | 
				
			||||||
                return Response('图片类型不存在', status_code=404)
 | 
					                return Response('图片类型不存在', status_code=404)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -47,11 +47,11 @@ async def rewrite_image(image_id: int):
 | 
				
			|||||||
            if img is None:
 | 
					            if img is None:
 | 
				
			||||||
                print('mysql中原始图片不存在:', image_id)
 | 
					                print('mysql中原始图片不存在:', image_id)
 | 
				
			||||||
                return Response('图片不存在', status_code=404)
 | 
					                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)
 | 
					            print('img_path', img_path)
 | 
				
			||||||
            image = download_image(img[0])
 | 
					            image = download_image(img['content'])
 | 
				
			||||||
            if image is None:
 | 
					            if image is None:
 | 
				
			||||||
                print('图片下载失败:', img[0])
 | 
					                print('图片下载失败:', img['content'])
 | 
				
			||||||
                return Response('图片下载失败', status_code=404)
 | 
					                return Response('图片下载失败', status_code=404)
 | 
				
			||||||
            image.save(img_path, 'png', save_all=True)
 | 
					            image.save(img_path, 'png', save_all=True)
 | 
				
			||||||
            with Image.open(img_path) as imgx:
 | 
					            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:
 | 
					                if img is None:
 | 
				
			||||||
                    print('mysql 中图片不存在:', image_id)
 | 
					                    print('mysql 中图片不存在:', image_id)
 | 
				
			||||||
                    return Response('图片不存在', status_code=404)
 | 
					                    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']))
 | 
				
			||||||
                image = download_image(img[0])
 | 
					                image = download_image(img['content'])
 | 
				
			||||||
                if image is None:
 | 
					                if image is None:
 | 
				
			||||||
                    print('图片下载失败:', img[0])
 | 
					                    print('图片下载失败:', img['content'])
 | 
				
			||||||
                    return Response('图片下载失败', status_code=404)
 | 
					                    return Response('图片下载失败', status_code=404)
 | 
				
			||||||
                image.save(img_path, 'png', save_all=True)
 | 
					                image.save(img_path, 'png', save_all=True)
 | 
				
			||||||
                with Image.open(img_path) as imgx:
 | 
					                with Image.open(img_path) as imgx:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user