Update README.md
Browse files
README.md
CHANGED
@@ -35,17 +35,17 @@ You can use the raw model for object detection. See the [model hub](https://hugg
|
|
35 |
Here is how to use this model:
|
36 |
|
37 |
```python
|
38 |
-
from transformers import
|
39 |
from PIL import Image
|
40 |
import requests
|
41 |
|
42 |
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
|
43 |
image = Image.open(requests.get(url, stream=True).raw)
|
44 |
|
45 |
-
|
46 |
model = YolosForObjectDetection.from_pretrained('hustvl/yolos-small-300')
|
47 |
|
48 |
-
inputs =
|
49 |
outputs = model(**inputs)
|
50 |
|
51 |
# model predicts bounding boxes and corresponding COCO classes
|
@@ -53,7 +53,7 @@ logits = outputs.logits
|
|
53 |
bboxes = outputs.pred_boxes
|
54 |
```
|
55 |
|
56 |
-
Currently, both the
|
57 |
|
58 |
## Training data
|
59 |
|
|
|
35 |
Here is how to use this model:
|
36 |
|
37 |
```python
|
38 |
+
from transformers import YolosImageProcessor, YolosForObjectDetection
|
39 |
from PIL import Image
|
40 |
import requests
|
41 |
|
42 |
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
|
43 |
image = Image.open(requests.get(url, stream=True).raw)
|
44 |
|
45 |
+
image_processor = YolosImageProcessor.from_pretrained('hustvl/yolos-small-300')
|
46 |
model = YolosForObjectDetection.from_pretrained('hustvl/yolos-small-300')
|
47 |
|
48 |
+
inputs = image_processor(images=image, return_tensors="pt")
|
49 |
outputs = model(**inputs)
|
50 |
|
51 |
# model predicts bounding boxes and corresponding COCO classes
|
|
|
53 |
bboxes = outputs.pred_boxes
|
54 |
```
|
55 |
|
56 |
+
Currently, both the image processor and model support PyTorch.
|
57 |
|
58 |
## Training data
|
59 |
|