-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enhancement] Support yolo-world model
- Loading branch information
Showing
10 changed files
with
349 additions
and
4 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
type: yolow | ||
name: yolow_l-r20240227 | ||
display_name: YOLO-World-L Tencent | ||
model_path: https://github.com/CVHub520/X-AnyLabeling/releases/download/v2.3.3/yolow-l.onnx | ||
confidence_threshold: 0.05 | ||
classes: | ||
- person | ||
- bicycle | ||
- car | ||
- motorcycle | ||
- airplane | ||
- bus | ||
- train | ||
- truck | ||
- boat | ||
- traffic light | ||
- fire hydrant | ||
- stop sign | ||
- parking meter | ||
- bench | ||
- bird | ||
- cat | ||
- dog | ||
- horse | ||
- sheep | ||
- cow | ||
- elephant | ||
- bear | ||
- zebra | ||
- giraffe | ||
- backpack | ||
- umbrella | ||
- handbag | ||
- tie | ||
- suitcase | ||
- frisbee | ||
- skis | ||
- snowboard | ||
- sports ball | ||
- kite | ||
- baseball bat | ||
- baseball glove | ||
- skateboard | ||
- surfboard | ||
- tennis racket | ||
- bottle | ||
- wine glass | ||
- cup | ||
- fork | ||
- knife | ||
- spoon | ||
- bowl | ||
- banana | ||
- apple | ||
- sandwich | ||
- orange | ||
- broccoli | ||
- carrot | ||
- hot dog | ||
- pizza | ||
- donut | ||
- cake | ||
- chair | ||
- couch | ||
- potted plant | ||
- bed | ||
- dining table | ||
- toilet | ||
- tv | ||
- laptop | ||
- mouse | ||
- remote | ||
- keyboard | ||
- cell phone | ||
- microwave | ||
- oven | ||
- toaster | ||
- sink | ||
- refrigerator | ||
- book | ||
- clock | ||
- vase | ||
- scissors | ||
- teddy bear | ||
- hair drier | ||
- toothbrush |
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
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import logging | ||
|
||
from PyQt5 import QtCore | ||
|
||
from anylabeling.app_info import __preferred_device__ | ||
from anylabeling.views.labeling.shape import Shape | ||
from anylabeling.views.labeling.utils.opencv import qt_img_to_rgb_cv_img | ||
from .types import AutoLabelingResult | ||
from .__base__.yolo import YOLO | ||
from .utils import denormalize_bbox | ||
|
||
|
||
class YOLOW(YOLO): | ||
"""https://github.com/AILab-CVC/YOLO-World""" | ||
|
||
def postprocess(self, outputs, image_shape): | ||
num_objs, bboxes, scores, class_ids = [out[0] for out in outputs] | ||
bboxes = [denormalize_bbox(bbox, self.input_shape, image_shape) for bbox in bboxes] | ||
return num_objs, bboxes, scores, class_ids | ||
|
||
def predict_shapes(self, image, image_path=None): | ||
""" | ||
Predict shapes from image | ||
""" | ||
|
||
if image is None: | ||
return [] | ||
|
||
try: | ||
image = qt_img_to_rgb_cv_img(image, image_path) | ||
except Exception as e: # noqa | ||
logging.warning("Could not inference model") | ||
logging.warning(e) | ||
return [] | ||
|
||
blob = self.preprocess(image, upsample_mode="resize") | ||
outputs = self.net.get_ort_inference(blob, extract=False) | ||
_, bboxes, scores, class_ids = self.postprocess(outputs, image.shape[:2]) | ||
|
||
shapes = [] | ||
for bbox, score, cls_id in zip(bboxes, scores, class_ids): | ||
if score < self.conf_thres or (int(cls_id) == -1): | ||
continue | ||
xmin, ymin, xmax, ymax = bbox | ||
rectangle_shape = Shape( | ||
label=str(self.classes[int(cls_id)]), | ||
shape_type="rectangle", | ||
) | ||
rectangle_shape.add_point(QtCore.QPointF(xmin, ymin)) | ||
rectangle_shape.add_point(QtCore.QPointF(xmax, ymin)) | ||
rectangle_shape.add_point(QtCore.QPointF(xmax, ymax)) | ||
rectangle_shape.add_point(QtCore.QPointF(xmin, ymax)) | ||
shapes.append(rectangle_shape) | ||
|
||
result = AutoLabelingResult(shapes, replace=True) | ||
|
||
return result |
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
Oops, something went wrong.