Update README.md
Browse files
README.md
CHANGED
@@ -57,13 +57,14 @@ print(entities)
|
|
57 |
Once you have the `entities`, you can use the following helper function to draw their bounding bboxes on the image:
|
58 |
|
59 |
```python
|
60 |
-
import
|
61 |
import numpy as np
|
|
|
|
|
62 |
import torch
|
63 |
-
from PIL import Image
|
64 |
import torchvision.transforms as T
|
65 |
-
|
66 |
-
import
|
67 |
|
68 |
|
69 |
def is_overlapping(rect1, rect2):
|
@@ -178,6 +179,10 @@ def draw_entity_boxes_on_image(image, entities, show=False, save_path=None):
|
|
178 |
return new_image
|
179 |
|
180 |
|
|
|
|
|
|
|
|
|
181 |
# From the previous code example
|
182 |
entities = [('a snowman', (12, 21), [(0.390625, 0.046875, 0.984375, 0.828125)]), ('a fire', (41, 47), [(0.171875, 0.015625, 0.484375, 0.890625)])]
|
183 |
|
|
|
57 |
Once you have the `entities`, you can use the following helper function to draw their bounding bboxes on the image:
|
58 |
|
59 |
```python
|
60 |
+
import cv2
|
61 |
import numpy as np
|
62 |
+
import os
|
63 |
+
import requests
|
64 |
import torch
|
|
|
65 |
import torchvision.transforms as T
|
66 |
+
|
67 |
+
from PIL import Image
|
68 |
|
69 |
|
70 |
def is_overlapping(rect1, rect2):
|
|
|
179 |
return new_image
|
180 |
|
181 |
|
182 |
+
# (The same image from the previous code example)
|
183 |
+
url = "https://huggingface.co/ydshieh/kosmos-2-patch14-224/resolve/main/snowman.jpg"
|
184 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
185 |
+
|
186 |
# From the previous code example
|
187 |
entities = [('a snowman', (12, 21), [(0.390625, 0.046875, 0.984375, 0.828125)]), ('a fire', (41, 47), [(0.171875, 0.015625, 0.484375, 0.890625)])]
|
188 |
|