animeic 2 years ago
parent
commit
be9fc8d152
3 changed files with 11 additions and 5 deletions
  1. BIN
      src/__pycache__/operators.cpython-310.pyc
  2. 2 0
      src/logs/milvus-2023-03-08.log
  3. 9 5
      src/main.py

BIN
src/__pycache__/operators.cpython-310.pyc


+ 2 - 0
src/logs/milvus-2023-03-08.log

@@ -0,0 +1,2 @@
+2023-03-08 10:49:02,796 | INFO | helpers.py | load_pretrained | 247 | Loading pretrained weights from url (https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-rsb-weights/resnet50_a1_0-14fe96d1.pth)
+2023-03-08 10:49:27,017 | ERROR | milvus_helpers.py | __init__ | 24 | Failed to connect Milvus: <MilvusException: (code=2, message=Fail connecting to server on 103.143.81.176:19530. Timeout)>

+ 9 - 5
src/main.py

@@ -105,14 +105,18 @@ async def upload_images(
 async def search_images(
     table_name: str = None,
     partition_names: list = [],
-    image: UploadFile = File(...),
+    # image: UploadFile = File(...),
+    url: str = None,
     limit: int = TOP_K
 ):
     try:
-        content = await image.read()
-        img_path = os.path.join(UPLOAD_PATH, image.filename)
-        with open(img_path, "wb+") as f:
-            f.write(content)
+        # content = await image.read()
+        # img_path = os.path.join(UPLOAD_PATH, image.filename)
+        # with open(img_path, "wb+") as f:
+        #     f.write(content)
+        if url is not None:
+            img_path = os.path.join(UPLOAD_PATH, os.path.basename(url))
+            urlretrieve(url, img_path)
         res = do_search(table_name,partition_names,img_path, limit, MODEL, MILVUS_CLI)
         list = []
         for hits in res: