You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "Apricot256 (via GitHub)" <gi...@apache.org> on 2023/12/21 08:22:35 UTC
[I] [Bug] [Pillow] AttributeError: 'ImageDraw' object has no attribute 'textsize' in draw_detections() [tvm]
Apricot256 opened a new issue, #16268:
URL: https://github.com/apache/tvm/issues/16268
### Expected behavior
Follow the [Compile YOLO-V2 and YOLO-V3 in DarkNet Models](https://tvm.apache.org/docs/how_to/compile_models/from_darknet.html) guide to run YOLO and draw bounding boxes.
### Actual behavior
[Deprecations and removals in Pillow](https://pillow.readthedocs.io/en/stable/deprecations.html#font-size-and-offset-methodshttps://pillow.readthedocs.io/en/stable/deprecations.html#font-size-and-offset-methods)
According to the above documentation, the `ImageDraw.textsize()` method has been deprecated since pillow 9.2.0 and removed in pillow 10.0, resulting in an attribute error.
```
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[6], line 80
77 names = [x.strip() for x in content]
79 tvm.relay.testing.yolo_detection.show_detections(img, dets, thresh, names, last_layer.classes)
---> 80 tvm.relay.testing.yolo_detection.draw_detections(font_path, img, dets, thresh, names, last_layer.classes)
82 plt.imshow(img.transpose(1, 2, 0))
83 plt.show()
File /opt/tvm/python/tvm/relay/testing/yolo_detection.py:255, in draw_detections(font_path, im, dets, thresh, names, classes)
253 if valid:
254 rgb = detection["rgb"]
--> 255 label = _get_label(font_path, "".join(detection["labelstr"]), rgb)
256 _draw_box_width(
257 im,
258 detection["left"],
(...)
265 rgb[2],
266 )
267 _draw_label(im, detection["top"] + detection["width"], detection["left"], label, rgb)
File /opt/tvm/python/tvm/relay/testing/yolo_detection.py:321, in _get_label(font_path, labelstr, rgb)
319 testDraw = ImageDraw.Draw(Image.new("RGB", (1, 1)))
320 font = ImageFont.truetype(font_path, 25)
--> 321 width, height = testDraw.textsize(labelstr, font=font)
322 img = Image.new(
323 "RGB", (width, height), color=(int(rgb[0] * 255), int(rgb[1] * 255), int(rgb[2] * 255))
324 )
325 d = ImageDraw.Draw(img)
AttributeError: 'ImageDraw' object has no attribute 'textsize'
```
### Environment
- OS: Ubuntu 22.04.3 LTS (x86_64)
- TVM version: 0.15.dev0
- Pillow version 10.1.0
### Steps to reproduce
```python
tvm.relay.testing.yolo_detection.draw_detections(font_path, img, dets, thresh, names, last_layer.classes)
```
in [Compile YOLO-V2 and YOLO-V3 in DarkNet Models](https://tvm.apache.org/docs/how_to/compile_models/from_darknet.html).
### Triage
Please refer to the list of label tags [here](https://github.com/apache/tvm/wiki/Issue-Triage-Labels) to find the relevant tags and add them below in a bullet format (example below).
* needs-triage
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug] [Pillow] AttributeError: 'ImageDraw' object has no attribute 'textsize' in draw_detections() [tvm]
Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen closed issue #16268: [Bug] [Pillow] AttributeError: 'ImageDraw' object has no attribute 'textsize' in draw_detections()
URL: https://github.com/apache/tvm/issues/16268
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org