Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
@@ -6,31 +6,24 @@ tags:
|
|
6 |
- pytorch
|
7 |
datasets:
|
8 |
- wendys-llc/chkbx
|
9 |
-
widget:
|
10 |
-
- src: https://i.imgur.com/ExampleChecked.jpg
|
11 |
-
candidate_labels: unchecked, checked
|
12 |
-
example_title: Checked Box
|
13 |
-
- src: https://i.imgur.com/ExampleUnchecked.jpg
|
14 |
-
candidate_labels: unchecked, checked
|
15 |
-
example_title: Unchecked Box
|
16 |
---
|
17 |
|
18 |
# Checkbox Classifier
|
19 |
|
20 |
-
Binary classifier for checkbox states (checked/unchecked).
|
21 |
|
22 |
-
## Usage
|
23 |
|
24 |
```python
|
25 |
from transformers import pipeline
|
26 |
-
from PIL import Image
|
27 |
|
28 |
# Load pipeline
|
29 |
classifier = pipeline("image-classification",
|
30 |
model="wendys-llc/checkbox-classifier",
|
31 |
trust_remote_code=True)
|
32 |
|
33 |
-
#
|
|
|
34 |
image = Image.open("checkbox.jpg")
|
35 |
result = classifier(image)
|
36 |
print(result)
|
@@ -38,29 +31,30 @@ print(result)
|
|
38 |
# {'label': 'checked', 'score': 0.99},
|
39 |
# {'label': 'unchecked', 'score': 0.01}
|
40 |
# ]
|
41 |
-
|
42 |
-
# Get just the top prediction
|
43 |
-
top_result = classifier(image, top_k=1)
|
44 |
-
print(f"State: {top_result[0]['label']}")
|
45 |
```
|
46 |
|
47 |
-
##
|
48 |
-
|
49 |
-
- **Architecture**: EfficientNetV2-S
|
50 |
-
- **Input Size**: 128x128 RGB images
|
51 |
-
- **Training**: Mixed precision on A100 GPU
|
52 |
-
- **Validation Accuracy**: 97.1%
|
53 |
-
- **License**: Apache 2.0
|
54 |
|
55 |
-
|
|
|
|
|
|
|
56 |
|
57 |
-
|
58 |
-
-
|
59 |
-
|
60 |
-
|
|
|
61 |
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
-
|
65 |
-
- Trained on UI checkboxes, not paper forms
|
66 |
-
- Best performance when checkbox is clearly visible and not too small
|
|
|
6 |
- pytorch
|
7 |
datasets:
|
8 |
- wendys-llc/chkbx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
---
|
10 |
|
11 |
# Checkbox Classifier
|
12 |
|
13 |
+
Binary classifier for checkbox states (checked/unchecked).
|
14 |
|
15 |
+
## Usage with Transformers
|
16 |
|
17 |
```python
|
18 |
from transformers import pipeline
|
|
|
19 |
|
20 |
# Load pipeline
|
21 |
classifier = pipeline("image-classification",
|
22 |
model="wendys-llc/checkbox-classifier",
|
23 |
trust_remote_code=True)
|
24 |
|
25 |
+
# Predict
|
26 |
+
from PIL import Image
|
27 |
image = Image.open("checkbox.jpg")
|
28 |
result = classifier(image)
|
29 |
print(result)
|
|
|
31 |
# {'label': 'checked', 'score': 0.99},
|
32 |
# {'label': 'unchecked', 'score': 0.01}
|
33 |
# ]
|
|
|
|
|
|
|
|
|
34 |
```
|
35 |
|
36 |
+
## Direct Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
+
```python
|
39 |
+
from transformers import AutoModelForImageClassification, AutoImageProcessor
|
40 |
+
import torch
|
41 |
+
from PIL import Image
|
42 |
|
43 |
+
model = AutoModelForImageClassification.from_pretrained(
|
44 |
+
"wendys-llc/checkbox-classifier",
|
45 |
+
trust_remote_code=True
|
46 |
+
)
|
47 |
+
processor = AutoImageProcessor.from_pretrained("wendys-llc/checkbox-classifier")
|
48 |
|
49 |
+
image = Image.open("checkbox.jpg")
|
50 |
+
inputs = processor(images=image, return_tensors="pt")
|
51 |
+
|
52 |
+
with torch.no_grad():
|
53 |
+
outputs = model(**inputs)
|
54 |
+
logits = outputs.logits
|
55 |
+
predicted_class = logits.argmax(-1).item()
|
56 |
+
|
57 |
+
print(model.config.id2label[predicted_class])
|
58 |
+
```
|
59 |
|
60 |
+
## Accuracy: 97.1%
|
|
|
|