William Mattingly commited on
Commit ·
9cb5082
1
Parent(s): 7a04879
init
Browse files- README.md +71 -0
- demo.ipynb +0 -0
- output.JPG +0 -0
- page_103.jpg +0 -0
- YOLOv8-mgh.pt → yolo8v-mgh.pt +2 -2
README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## MGH Critical Edition YOLO Model
|
| 2 |
+
|
| 3 |
+
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.
|
| 4 |
+
|
| 5 |
+
### Dataset
|
| 6 |
+
|
| 7 |
+
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 manuscripts and their associated annotations.
|
| 8 |
+
|
| 9 |
+
### Training Details
|
| 10 |
+
|
| 11 |
+
- Architecture: YOLOv8n
|
| 12 |
+
- Pretrained Model: `yolov8n.pt`
|
| 13 |
+
- Image Size: 640
|
| 14 |
+
- Batch Size: 25
|
| 15 |
+
- Augmentation: Enabled
|
| 16 |
+
- Epochs: 300
|
| 17 |
+
|
| 18 |
+
### Evaluation Metrics
|
| 19 |
+
|
| 20 |
+
Forthcoming...
|
| 21 |
+
|
| 22 |
+
### Usage
|
| 23 |
+
|
| 24 |
+
To utilize this model in your projects, you can use the `ultralytics` YOLO library. Here's a simple code snippet to get you started:
|
| 25 |
+
|
| 26 |
+
```bash
|
| 27 |
+
git clone https://huggingface.co/medieval-data/yolov8-mgh
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
```bash
|
| 31 |
+
cd clone yolov8-mgh
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
```python
|
| 35 |
+
from ultralytics import YOLO
|
| 36 |
+
import cv2
|
| 37 |
+
from matplotlib import pyplot as plt
|
| 38 |
+
|
| 39 |
+
model = YOLO("yolo8v-mgh.pt")
|
| 40 |
+
|
| 41 |
+
# Prediction on an image
|
| 42 |
+
image_path = "page_103.jpg"
|
| 43 |
+
results = model(image_path)
|
| 44 |
+
|
| 45 |
+
# Visualize the results
|
| 46 |
+
results[0].boxes.data.tolist()
|
| 47 |
+
|
| 48 |
+
# Load the image
|
| 49 |
+
image = cv2.imread(image_path)
|
| 50 |
+
threshold = 0.5
|
| 51 |
+
# Draw bounding boxes on the image
|
| 52 |
+
for result in results[0].boxes.data.tolist():
|
| 53 |
+
x1, y1, x2, y2, score, class_id = result
|
| 54 |
+
if score > threshold:
|
| 55 |
+
cv2.rectangle(image, (int(x1), int(y1)), (int(x2), int(y2)), (0, 255, 0), 4)
|
| 56 |
+
cv2.putText(image, results[0].names[int(class_id)].upper(), (int(x1), int(y1 - 10)),
|
| 57 |
+
cv2.FONT_HERSHEY_SIMPLEX, 1.3, (0, 255, 0), 3, cv2.LINE_AA)
|
| 58 |
+
|
| 59 |
+
# Convert BGR image to RGB for plotting
|
| 60 |
+
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 61 |
+
|
| 62 |
+
# Display the image in the notebook
|
| 63 |
+
plt.figure(figsize=(10, 10))
|
| 64 |
+
plt.imshow(image_rgb)
|
| 65 |
+
plt.axis('off')
|
| 66 |
+
plt.show()
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
### Expected Output
|
| 70 |
+
|
| 71 |
+

|
demo.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
output.JPG
ADDED
|
|
page_103.jpg
ADDED
|
YOLOv8-mgh.pt → yolo8v-mgh.pt
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ca3fe79e74ac029eb0d23710b687dc56d8afe50cdbc36ec4a358e99cd13b1edf
|
| 3 |
+
size 6246169
|