import base64
from box_utils import cxywh2ltrb, cxywh2xywh
def style():
""" Style string for card models
"""
return """
"""
def convert_img_url(img_url):
return img_url.replace('http://images.cocodataset.org', 'https://s3.us-east-1.amazonaws.com/images.cocodataset.org')
def card(img_url, img_w, img_h, boxes):
""" This is a hack to streamlit
Solution thanks to: https://discuss.streamlit.io/t/display-svg/172/5
Converting SVG to Base64 and display with tag.
Also we used the
"""
_boxes = ""
img_url = convert_img_url(img_url)
for b in boxes:
_id, cx, cy, w, h, label, logit, is_selected = b[:8]
x, y, w, h = cxywh2xywh(cx, cy, w, h)
x = round(img_w * x)
y = round(img_h * y)
w = round(img_w * w)
h = round(img_h * h)
logit = "%.3f" % logit
_boxes += f'''