Run this model with HF Jobs
Run SpotLab/YOLOv8Detection on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/SpotLab/YOLOv8Detection. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/SpotLab/YOLOv8Detection on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use SpotLab/YOLOv8Detection with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SpotLab/YOLOv8Detection with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("object-detection", model="SpotLab/YOLOv8Detection")# pip install -U transformers accelerate # Load model directly from transformers import Yolov8ForObjectDetection model = Yolov8ForObjectDetection.from_pretrained("SpotLab/YOLOv8Detection", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Jaime García Villena commited on
Commit ·
48730f0
1
Parent(s): 7cd0692
get the script to export
Browse filesFiles changed (11)
- yolo_export.pyAdded+6
- yolo_run.pyAdded+76
- yolov8n.onnxAdded+3
- yolov8n.ptAdded+3
- yolov8n_saved_model/fingerprint.pbAdded+3
- yolov8n_saved_model/metadata.yamlAdded+92
- yolov8n_saved_model/saved_model.pbAdded+3
- yolov8n_saved_model/variables/variables.data-00000-of-00001Added
- yolov8n_saved_model/variables/variables.indexAdded
- yolov8n_saved_model/yolov8n_float16.tfliteAdded+3
- yolov8n_saved_model/yolov8n_float32.tfliteAdded+3
123456from ultralytics import YOLO
if __name__ == '__main__': model = YOLO('yolov8n.pt') model.export(format = 'saved_model', keras = True) model.export(format = 'tflite')12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576from ultralytics import YOLO"""Created on Wed Oct 4 16:44:12 2023
@author: lin"""import globimport syssys.path.append('../../..')import osimport cv2import jsonimport tensorflow as tfimport numpy as npimport matplotlib.pyplot as plt# from utils.bbox_op import non_max_supression
def plot_prediction(image_np, bboxes, classes, scores, label_map): color=(255,0,0) thickness=5 font_scale=3
for i, box in enumerate(bboxes): box = bboxes[i, :] x0, y0, x1, y1 = box
xmin = int(x0) ymin = int(y0) xmax = int(x1) ymax = int(y1)
print(xmin, ymin, xmax, ymax) image_np = cv2.rectangle(image_np, (xmin, ymin), (xmax, ymax), color=color, thickness=thickness) text_x = xmin - 10 if xmin > 20 else xmin + 10 text_y = ymin - 10 if ymin > 20 else ymin + 10 display_str = label_map[str(int(classes))]
cv2.putText( image_np, display_str, (text_x, text_y), cv2.FONT_HERSHEY_SIMPLEX, font_scale, color, thickness, ) plt.imshow(image_np) plt.show()
if __name__ == "__main__": min_th = 0.1 labels_json = "coco_labels.json" with open(labels_json) as f: label_map = json.load(f) img_path = "test_images" saved_tflite = "tflite_model.tflite" # load model model = YOLO("yolov8n.pt") images = glob.glob(os.path.join(img_path, "*")) for img in images: image_np = cv2.imread(img) # gpreprocess(img) image_np = cv2.cvtColor(image_np, cv2.COLOR_BGR2RGB) # print(image_np.shape) # image_np = np.array(Image.open(image_path)) results = model(img) boxes = results[0].boxes
print(boxes.xyxy) print(boxes.cls) print(boxes.conf) plot_prediction(image_np, boxes.xyxy.numpy(), boxes.cls.numpy(), boxes.conf.numpy(), label_map)123version https://git-lfs.github.com/spec/v1oid sha256:dd48a79dd7fec8ca25fde4eca742ff7bca23b27e2e903eb23bc1d9f83a459bd2size 12769720123version https://git-lfs.github.com/spec/v1oid sha256:31e20dde3def09e2cf938c7be6fe23d9150bbbe503982af13345706515f2ef95size 6534387123version https://git-lfs.github.com/spec/v1oid sha256:3b3492909f2891a54e9151b18733a1d42d514bea74240f213228f33eac6a017asize 561234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192description: Ultralytics YOLOv8n model trained on coco.yamlauthor: Ultralyticslicense: AGPL-3.0 https://ultralytics.com/licensedate: '2023-10-06T15:50:35.220556'version: 8.0.192stride: 32task: detectbatch: 1imgsz:- 640- 640names: 0: person 1: bicycle 2: car 3: motorcycle 4: airplane 5: bus 6: train 7: truck 8: boat 9: traffic light 10: fire hydrant 11: stop sign 12: parking meter 13: bench 14: bird 15: cat 16: dog 17: horse 18: sheep 19: cow 20: elephant 21: bear 22: zebra 23: giraffe 24: backpack 25: umbrella 26: handbag 27: tie 28: suitcase 29: frisbee 30: skis 31: snowboard 32: sports ball 33: kite 34: baseball bat 35: baseball glove 36: skateboard 37: surfboard 38: tennis racket 39: bottle 40: wine glass 41: cup 42: fork 43: knife 44: spoon 45: bowl 46: banana 47: apple 48: sandwich 49: orange 50: broccoli 51: carrot 52: hot dog 53: pizza 54: donut 55: cake 56: chair 57: couch 58: potted plant 59: bed 60: dining table 61: toilet 62: tv 63: laptop 64: mouse 65: remote 66: keyboard 67: cell phone 68: microwave 69: oven 70: toaster 71: sink 72: refrigerator 73: book 74: clock 75: vase 76: scissors 77: teddy bear 78: hair drier 79: toothbrush123version https://git-lfs.github.com/spec/v1oid sha256:f23f3eda89025c6d1da3916c7fed1a50179bb9182aedca2d6a74ba0f39fb2a23size 12913757123version https://git-lfs.github.com/spec/v1oid sha256:72e4cbf64265e974923d6b723a2be1d1deeacbdc74aa770e5e82a9f0b753c645size 6434532123version https://git-lfs.github.com/spec/v1oid sha256:435e0b6375a32b862ed30cb630256d5dbefb9597c53c87125a66e44ab26cfd68size 12771680yolo_export.pyAdded+6
yolo_run.pyAdded+76
yolov8n.onnxAdded+3
yolov8n.ptAdded+3
yolov8n_saved_model/fingerprint.pbAdded+3
yolov8n_saved_model/metadata.yamlAdded+92
yolov8n_saved_model/saved_model.pbAdded+3
yolov8n_saved_model/variables/variables.data-00000-of-00001Added
yolov8n_saved_model/variables/variables.indexAdded
yolov8n_saved_model/yolov8n_float16.tfliteAdded+3
yolov8n_saved_model/yolov8n_float32.tfliteAdded+3