Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from streamlit_drawable_canvas import st_canvas | |
| from huggingface_hub import HfFileSystem | |
| from flax.serialization import msgpack_restore, from_state_dict | |
| fs = HfFileSystem() | |
| with fs.open("PrakhAI/HelloWorld/checkpoint.msgpack", "rb") as f: | |
| state = msgpack_restore(f.read()) | |
| print(type(state)) | |
| print(state) | |
| print([(k, type(v)) for (k, v) in state.items()]) | |
| # print(state['params']) | |
| # print(state['opt_state']) | |
| # logits = state.apply_fn({'params': state.params}, batch['image']) | |
| # print(logits) | |
| # x = st.slider('Select a value') | |
| # st.write(x, 'squared is', x * x) | |
| def canvas_main(): | |
| canvas_result = st_canvas( | |
| fill_color="rgba(255, 165, 0, 0.3)", # Fixed fill color with some opacity | |
| stroke_width=st.sidebar.slider("Brush width: ", 1, 100, 10), | |
| stroke_color=st.sidebar.color_picker("Enter brush color hex: "), | |
| background_color=st.sidebar.color_picker("Enter background color hex: ", "#eee"), | |
| background_image=None, | |
| update_streamlit=st.sidebar.checkbox("Update in realtime", True), | |
| height=150, | |
| drawing_mode=st.sidebar.checkbox("Drawing mode ?", True), | |
| point_display_radius=point_display_radius if st.sidebar.selectbox( | |
| "Drawing tool:", | |
| ("freedraw", "line", "rect", "circle", "transform", "polygon", "point"), | |
| ) == "point" else 0, | |
| display_toolbar=st.sidebar.checkbox("Display toolbar", True), | |
| key="canvas_main", | |
| ) | |
| # Do something interesting with the image data and paths | |
| if canvas_result.image_data is not None: | |
| st.image(canvas_result.image_data) | |
| canvas_main() | |