-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image Display Broken #10
Comments
Yes! I solved it (hackily) like this, where I had a def display_fn(x):
value = x.value
if "[" in value:
value = literal_eval(value.replace("<style>div.output_scroll { height: 88em; width: 100%}</style>", "").replace("<body><div>", "").replace("</div></body>", ""))
value = display(Image(value[1]))
return x
annotations = pixt.annotate(
list_of_data,
options=list_labels,
display_fn=display_fn
) Not optimal. Proposed solution: The decoration shouldn't be passed to the |
Could you elaborate more on your fix as I am running into this problem as well and am unable to figure out how exactly I should implement your fix?
|
This is working for me. But it should be fixed in the package imho. def display_fn(x):
value = x.value
value = value.replace("<style>div.output_scroll { height: 88em; width: 100%}</style>", "").replace("<body><div>", "").replace("</div></body>", "")
value = display(Image(value))
return x
annotations = pixt.annotate(
df,
options=['test', 'example'],
display_fn=display_fn
) |
Definitely, hard agree @thaasch ! |
import re
from IPython.display import display, Image
def custom_display(html_content):
# Convert HTML object to string
html_string = str(html_content)
# Use regular expression to extract the text inside <div> tags
match = re.search(r'<div>(.*?)</div>', html_string)
if match:
image_path = match.group(1)
display(Image(filename=image_path))
else:
print("No image path found in HTML content")
# Example usage in pigeonXT.annotate
data_dict = pixt.annotate(
file_list,
options=['...'],
display_fn=custom_display
) Same problem, ended up using this regular expression |
I believe this line breaks the image display example
decorated_text = HTML(style_text + f"<body><div>{example_text}</div></body>")
The text was updated successfully, but these errors were encountered: