Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,68 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Model Card for Pixelated Captcha Digit Detection
|
| 2 |
+
|
| 3 |
+
## Model Details
|
| 4 |
+
|
| 5 |
+
- **License:** Apache-2.0
|
| 6 |
+
- **Developed by:** Saidi Souhaieb
|
| 7 |
+
- **Finetuned from model:** YOLOv8
|
| 8 |
+
|
| 9 |
+
## Uses
|
| 10 |
+
|
| 11 |
+
This model is designed to detect pixelated captcha digits by showing bounding boxes and extracting the coordinates of the detections.
|
| 12 |
+
|
| 13 |
+
## How to Get Started with the Model
|
| 14 |
+
|
| 15 |
+
```python
|
| 16 |
+
from PIL import Image, ImageDraw
|
| 17 |
+
from YOLO import YOLO # Assuming YOLO is a class in a module named YOLO
|
| 18 |
+
|
| 19 |
+
# Load the model
|
| 20 |
+
model = YOLO("models/number_finder.pt")
|
| 21 |
+
|
| 22 |
+
# Get model results
|
| 23 |
+
model_results = model(image_path)
|
| 24 |
+
img = Image.open(image_path)
|
| 25 |
+
draw = ImageDraw.Draw(img)
|
| 26 |
+
|
| 27 |
+
# Sort results based on the x-coordinate
|
| 28 |
+
detected_objects = []
|
| 29 |
+
captcha_result = ""
|
| 30 |
+
boxes_data = []
|
| 31 |
+
|
| 32 |
+
for result in model_results:
|
| 33 |
+
for box in result.boxes:
|
| 34 |
+
box_data = {"xyxy": box.xyxy[0].tolist(),
|
| 35 |
+
"label": str(box.cls.item())}
|
| 36 |
+
boxes_data.append(box_data)
|
| 37 |
+
|
| 38 |
+
sorted_boxes_data = sorted(boxes_data, key=lambda x: x['xyxy'][0])
|
| 39 |
+
|
| 40 |
+
# Remove similar boxes
|
| 41 |
+
unique_sorted_boxes_data = [sorted_boxes_data[0]]
|
| 42 |
+
for i in range(1, len(sorted_boxes_data)):
|
| 43 |
+
current_box = sorted_boxes_data[i]
|
| 44 |
+
prev_box = unique_sorted_boxes_data[-1]
|
| 45 |
+
# Check if the current box's x-coordinate is significantly different from the previous box
|
| 46 |
+
if abs(current_box['xyxy'][0] - prev_box['xyxy'][0]) > 1: # Adjust threshold as needed
|
| 47 |
+
unique_sorted_boxes_data.append(current_box)
|
| 48 |
+
|
| 49 |
+
for box in unique_sorted_boxes_data:
|
| 50 |
+
label_name = box["label"]
|
| 51 |
+
box_coords = box["xyxy"]
|
| 52 |
+
detected_objects.append((box_coords))
|
| 53 |
+
draw.rectangle(box_coords, outline="red")
|
| 54 |
+
draw.text((box_coords[0], box_coords[1] - 10), label_name, fill="red")
|
| 55 |
+
captcha_result += str(int(label_name[0]) - 2)
|
| 56 |
+
img.show() # Display the image with bounding boxes and labels
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
## Training Details
|
| 60 |
+
|
| 61 |
+
### Training Data
|
| 62 |
+
|
| 63 |
+
Raw Pixel Digit Captcha Data []
|
| 64 |
+
|
| 65 |
+
## Model Card Authors [optional]
|
| 66 |
+
|
| 67 |
+
[Saidi Souhaieb]
|
| 68 |
+
|