Object Detection
yolov8-mgh / README.md
wjbmattingly's picture
Update README.md
ab0f06f
---
license: cc-by-nc-2.0
datasets:
- medieval-data/mgh-critical-edition-layout
pipeline_tag: object-detection
---
## MGH Critical Edition YOLO Model
This repository hosts a YOLO model specifically trained to detect and annotate various elements from medieval manuscripts. The model is built and trained using the Ultralytics YOLOv8n architecture.
### Dataset
The model is trained on the dataset available at: [medieval-data/mgh-critical-edition-layout](https://huggingface.co/datasets/medieval-data/mgh-critical-edition-layout). This dataset comprises images from medieval critical editions and their associated annotations.
### Training Details
- Architecture: YOLOv8n
- Pretrained Model: `yolov8n.pt`
- Image Size: 640
- Batch Size: 25
- Augmentation: Enabled
- Epochs: 300
### Evaluation Metrics
Forthcoming...
### Usage
To utilize this model in your projects, you can use the `ultralytics` YOLO library. Here's a simple code snippet to get you started:
```bash
git clone https://huggingface.co/medieval-data/yolov8-mgh
```
```bash
cd clone yolov8-mgh
```
```python
from ultralytics import YOLO
import cv2
from matplotlib import pyplot as plt
model = YOLO("yolo8v-mgh.pt")
# Prediction on an image
image_path = "page_103.jpg"
results = model(image_path)
# Visualize the results
results[0].boxes.data.tolist()
# Load the image
image = cv2.imread(image_path)
threshold = 0.5
# Draw bounding boxes on the image
for result in results[0].boxes.data.tolist():
x1, y1, x2, y2, score, class_id = result
if score > threshold:
cv2.rectangle(image, (int(x1), int(y1)), (int(x2), int(y2)), (0, 255, 0), 4)
cv2.putText(image, results[0].names[int(class_id)].upper(), (int(x1), int(y1 - 10)),
cv2.FONT_HERSHEY_SIMPLEX, 1.3, (0, 255, 0), 3, cv2.LINE_AA)
# Convert BGR image to RGB for plotting
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
# Display the image in the notebook
plt.figure(figsize=(10, 10))
plt.imshow(image_rgb)
plt.axis('off')
plt.show()
```
### Expected Output
![outout](output.JPG)