Spaces:
Sleeping
Sleeping
File size: 981 Bytes
47632c6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import pandas as pd
import streamlit as st
from PIL import Image
def load_background_image(bg_image):
"""
Loads the background image from the uploaded file if provided.
Args:
bg_image: The file uploaded by the user for background.
Returns:
PIL Image object or None if no file is uploaded.
"""
return Image.open(bg_image) if bg_image else None
def display_canvas_data(canvas_result):
"""
Display the image data and JSON object data from the canvas result.
Args:
canvas_result: Result object returned by st_canvas.
"""
if canvas_result.image_data is not None:
st.image(canvas_result.image_data)
if canvas_result.json_data is not None:
objects = pd.json_normalize(canvas_result.json_data["objects"]) # Flatten JSON data
for col in objects.select_dtypes(include=['object']).columns:
objects[col] = objects[col].astype("str")
st.dataframe(objects)
|