Update README.md
Browse files
README.md
CHANGED
@@ -1,12 +1,19 @@
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
-
tags:
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
---
|
5 |
|
6 |
-
#
|
7 |
|
8 |
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
|
|
|
10 |
|
11 |
|
12 |
## Model Details
|
@@ -14,8 +21,8 @@ tags: []
|
|
14 |
### Model Description
|
15 |
|
16 |
<!-- Provide a longer summary of what this model is. -->
|
|
|
17 |
|
18 |
-
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
19 |
|
20 |
- **Developed by:** [More Information Needed]
|
21 |
- **Funded by [optional]:** [More Information Needed]
|
@@ -37,10 +44,37 @@ This is the model card of a 🤗 transformers model that has been pushed on the
|
|
37 |
|
38 |
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
|
40 |
-
###
|
41 |
|
42 |
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
[More Information Needed]
|
45 |
|
46 |
### Downstream Use [optional]
|
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
+
tags:
|
4 |
+
- object-detection
|
5 |
+
- vision
|
6 |
+
- chess
|
7 |
+
license: apache-2.0
|
8 |
+
base_model:
|
9 |
+
- facebook/detr-resnet-50
|
10 |
---
|
11 |
|
12 |
+
# DETR (End-to-End Object Detection) model with ResNet-50 backbone fine-tuned on chess pieces
|
13 |
|
14 |
<!-- Provide a quick summary of what the model is/does. -->
|
15 |
|
16 |
+
DEtection TRansformer (DETR) model trained end-to-end on Chess pieces recognition dataset
|
17 |
|
18 |
|
19 |
## Model Details
|
|
|
21 |
### Model Description
|
22 |
|
23 |
<!-- Provide a longer summary of what this model is. -->
|
24 |
+
The DETR model is an encoder-decoder transformer with a convolutional backbone. Two heads are added on top of the decoder outputs in order to perform object detection: a linear layer for the class labels and a MLP (multi-layer perceptron) for the bounding boxes. The model uses so-called object queries to detect objects in an image. Each object query looks for a particular object in the image. For COCO, the number of object queries is set to 100.
|
25 |
|
|
|
26 |
|
27 |
- **Developed by:** [More Information Needed]
|
28 |
- **Funded by [optional]:** [More Information Needed]
|
|
|
44 |
|
45 |
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
46 |
|
47 |
+
### How To Use
|
48 |
|
49 |
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
50 |
|
51 |
+
```python
|
52 |
+
from transformers import DetrImageProcessor, DetrForObjectDetection
|
53 |
+
import torch
|
54 |
+
from PIL import Image
|
55 |
+
import requests
|
56 |
+
|
57 |
+
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
58 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
59 |
+
|
60 |
+
processor = DetrImageProcessor.from_pretrained("aesat/detr-finetuned-chess", revision="no_timm")
|
61 |
+
model = DetrForObjectDetection.from_pretrained("facebook/detr-finetuned-chess", revision="no_timm")
|
62 |
+
|
63 |
+
inputs = processor(images=image, return_tensors="pt")
|
64 |
+
outputs = model(**inputs)
|
65 |
+
|
66 |
+
# convert outputs (bounding boxes and class logits) to COCO API
|
67 |
+
# let's only keep detections with score > 0.9
|
68 |
+
target_sizes = torch.tensor([image.size[::-1]])
|
69 |
+
results = processor.post_process_object_detection(outputs, target_sizes=target_sizes, threshold=0.9)[0]
|
70 |
+
|
71 |
+
for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
|
72 |
+
box = [round(i, 2) for i in box.tolist()]
|
73 |
+
print(
|
74 |
+
f"Detected {model.config.id2label[label.item()]} with confidence "
|
75 |
+
f"{round(score.item(), 3)} at location {box}"
|
76 |
+
)
|
77 |
+
```
|
78 |
[More Information Needed]
|
79 |
|
80 |
### Downstream Use [optional]
|