pedromiguelsanchez commited on
Commit
21cec94
1 Parent(s): f07b2a2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +29 -0
README.md CHANGED
@@ -22,6 +22,35 @@ Training dataset from https://www.kaggle.com/datasets/alexo98/leaf-detection
22
 
23
  Dataset adaptation to YOLO format from https://www.kaggle.com/code/luisolazo/leaf-detection-w-ultralytics-yolov8-and-tflite
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  ## Examples
26
 
27
 
 
22
 
23
  Dataset adaptation to YOLO format from https://www.kaggle.com/code/luisolazo/leaf-detection-w-ultralytics-yolov8-and-tflite
24
 
25
+ ## Usage
26
+
27
+ ```python
28
+ from ultralytics import YOLO
29
+ import cv2
30
+ import matplotlib.pyplot as plt
31
+
32
+ # Load the YOLO model
33
+ model = YOLO('yolo11x_leaf.pt')
34
+
35
+ # Run inference on an image or directory
36
+ result = model.predict('file/directory', task="detect", save=False, conf=0.15)
37
+
38
+ # Load the original image
39
+ image_path = result.path
40
+ image = cv2.imread(image_path)
41
+ image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
42
+
43
+ # Annotate the image with predictions
44
+ annotated_image = result.plot()
45
+
46
+ # Display the annotated image
47
+ plt.figure(figsize=(10, 7))
48
+ plt.imshow(annotated_image)
49
+ plt.axis("off")
50
+ plt.title(f"Predictions for Image")
51
+ plt.show()
52
+ ```
53
+
54
  ## Examples
55
 
56