iarbel commited on
Commit
d349524
1 Parent(s): c8bd9af

Upload folder using huggingface_hub

Browse files
Files changed (6) hide show
  1. .gitattributes +0 -1
  2. README.md +67 -0
  3. config.json +1 -0
  4. handler.py +52 -0
  5. requirements.txt +1 -0
  6. yolov8s.pt +3 -0
.gitattributes CHANGED
@@ -25,7 +25,6 @@
25
  *.safetensors filter=lfs diff=lfs merge=lfs -text
26
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
  *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
  *.tflite filter=lfs diff=lfs merge=lfs -text
30
  *.tgz filter=lfs diff=lfs merge=lfs -text
31
  *.wasm filter=lfs diff=lfs merge=lfs -text
 
25
  *.safetensors filter=lfs diff=lfs merge=lfs -text
26
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
  *.tar.* filter=lfs diff=lfs merge=lfs -text
 
28
  *.tflite filter=lfs diff=lfs merge=lfs -text
29
  *.tgz filter=lfs diff=lfs merge=lfs -text
30
  *.wasm filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ---
3
+ tags:
4
+ - ultralyticsplus
5
+ - ultralytics
6
+ - yolov8
7
+ - yolo
8
+ - vision
9
+ - object-detection
10
+ - pytorch
11
+ library_name: ultralytics
12
+ library_version: 8.0.4
13
+ inference: false
14
+
15
+ model-index:
16
+ - name: ultralyticsplus/yolov8s
17
+ results:
18
+ - task:
19
+ type: object-detection
20
+
21
+ metrics:
22
+ - type: precision # since mAP is not available on hf.co/metrics
23
+ value: 0.449 # min: 0.0 - max: 1.0
24
+ name: mAP
25
+ ---
26
+
27
+ ### Supported Labels
28
+
29
+ ```
30
+ ['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']
31
+ ```
32
+
33
+
34
+ ### How to use
35
+
36
+ - Install [ultralyticsplus](https://github.com/fcakyon/ultralyticsplus):
37
+
38
+ ```bash
39
+ pip install -U ultralyticsplus==0.0.14
40
+ ```
41
+
42
+ - Load model and perform prediction:
43
+
44
+ ```python
45
+ from ultralyticsplus import YOLO, render_result
46
+
47
+ # load model
48
+ model = YOLO('ultralyticsplus/yolov8s')
49
+
50
+ # set model parameters
51
+ model.overrides['conf'] = 0.25 # NMS confidence threshold
52
+ model.overrides['iou'] = 0.45 # NMS IoU threshold
53
+ model.overrides['agnostic_nms'] = False # NMS class-agnostic
54
+ model.overrides['max_det'] = 1000 # maximum number of detections per image
55
+
56
+ # set image
57
+ image = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg'
58
+
59
+ # perform inference
60
+ results = model.predict(image)
61
+
62
+ # observe results
63
+ print(results[0].boxes)
64
+ render = render_result(model=model, image=image, result=results[0])
65
+ render.show()
66
+ ```
67
+
config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"input_size": 640, "task": "object-detection", "best_ap": 0.449}
handler.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ultralyticsplus import YOLO
2
+ from typing import Dict, Any, Optional, List
3
+ from sahi import ObjectPrediction
4
+
5
+
6
+ DEFAULT_CONFIG = {'conf': 0.25, 'iou': 0.45, 'agnostic_nms': False, 'max_det': 1000}
7
+
8
+
9
+ class EndpointHandler():
10
+ def __init__(self):
11
+ self.model = YOLO('ultralyticsplus/yolov8s')
12
+
13
+ def __call__(self, image, config: Optional[Dict[str, Any]] = None) -> List[ObjectPrediction]:
14
+ """
15
+ data args:
16
+ image: image path to segment
17
+ config: (conf - NMS confidence threshold,
18
+ iou - NMS IoU threshold,
19
+ agnostic_nms - NMS class-agnostic: True / False,
20
+ max_det - maximum number of detections per image)
21
+ Return:
22
+ object_predictions
23
+ """
24
+ if config is None:
25
+ config = DEFAULT_CONFIG
26
+ # Set model parameters
27
+ self.model.overrides['conf'] = config.get('conf')
28
+ self.model.overrides['iou'] = config.get('iou')
29
+ self.model.overrides['agnostic_nms'] = config.get('agnostic_nms')
30
+ self.model.overrides['max_det'] = config.get('max_det')
31
+
32
+ # perform inference
33
+ result = self.model.predict(image)[0]
34
+
35
+ names = self.model.model.names
36
+ boxes = result.boxes
37
+
38
+ object_predictions = []
39
+ if boxes is not None:
40
+ det_ind = 0
41
+ for xyxy, conf, cls in zip(boxes.xyxy, boxes.conf, boxes.cls):
42
+ object_prediction = ObjectPrediction(
43
+ bbox=xyxy.tolist(),
44
+ category_name=names[int(cls)],
45
+ category_id=int(cls),
46
+ score=conf,
47
+ )
48
+ object_predictions.append(object_prediction)
49
+ det_ind += 1
50
+
51
+ return object_predictions
52
+
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ ultralyticsplus==0.0.14
yolov8s.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:268e5bb54c640c96c3510224833bc2eeacab4135c6deb41502156e39986b562d
3
+ size 22573363