-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1046 from shiyu22/towhee0.6
Update to Milvus2.0.2 and Towhee0.6
- Loading branch information
Showing
40 changed files
with
124 additions
and
1,335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 25 additions & 17 deletions
42
solutions/reverse_image_search/object_detection/server/src/encode.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,33 @@ | ||
from towhee import pipeline | ||
import towhee | ||
import cv2 | ||
from numpy import linalg as LA | ||
|
||
# os.environ['KERAS_HOME'] = os.path.abspath(os.path.join('.', 'data')) | ||
|
||
|
||
class CustomOperator: | ||
""" | ||
Say something about the ExampleCalass... | ||
Args: | ||
args_0 (`type`): | ||
... | ||
""" | ||
def __init__(self): | ||
#self.img_embedding = pipeline('image-embedding') | ||
self.yolo_embedding = pipeline('shiyu/img_object_embedding_pytorch_yolov5_resnet50') | ||
|
||
def execute(self, img_path): | ||
objs = self.yolo_embedding(img_path) | ||
boxes, _, _ = towhee.glob(img_path) \ | ||
.image_decode() \ | ||
.object_detection.yolov5() \ | ||
.to_list()[0] | ||
|
||
imgs = self.get_imgs_list(img_path, boxes) | ||
embeddings = towhee.dc(imgs) \ | ||
.image_embedding.timm(model_name='resnet50') \ | ||
.to_list() | ||
|
||
norm_objs = [] | ||
for feat in objs: | ||
norm_feat = feat[0] / LA.norm(feat[0]) | ||
for feat in embeddings: | ||
norm_feat = feat / LA.norm(feat) | ||
norm_objs.append(norm_feat.tolist()) | ||
return norm_objs | ||
|
||
|
||
@staticmethod | ||
def get_imgs_list(img_path, boxes): | ||
img_list = [] | ||
img = cv2.imread(img_path) | ||
|
||
for box in boxes: | ||
tmp_obj = img[int(box[1]):int(box[3]), int(box[0]):int(box[2])] | ||
img_list.append(towhee._types.Image(tmp_obj, 'BGR')) | ||
return img_list |
36 changes: 0 additions & 36 deletions
36
solutions/reverse_image_search/object_detection/server/src/encode_resnet50.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
26 changes: 0 additions & 26 deletions
26
...ns/reverse_image_search/object_detection/server/src/yolov3_detector/data/prepare_model.sh
This file was deleted.
Oops, something went wrong.
167 changes: 0 additions & 167 deletions
167
solutions/reverse_image_search/object_detection/server/src/yolov3_detector/paddle_yolo.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.