Spaces:
Running
Running
File size: 853 Bytes
0e8c927 c915f7c 0e8c927 0e02e00 c915f7c 0e02e00 0e8c927 1ba3d0b c915f7c 0e02e00 0e8c927 |
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 |
import streamlit as st
def metadata2md(image_hash:str, debug:bool=False) -> str:
"""Get metadata from cache and return as markdown-formatted key-value list
Args:
image_hash (str): The hash of the image to get metadata for
debug (bool, optional): Whether to print additional fields.
Returns:
str: Markdown-formatted key-value list of metadata
"""
markdown_str = "\n"
keys_to_print = ["author_email", "latitude", "longitude", "date", "time"]
if debug:
keys_to_print += ["iamge_md5", "selected_class", "top_prediction", "class_overriden"]
observation = st.session_state.public_observations.get(image_hash, {})
for key, value in observation.items():
if key in keys_to_print:
markdown_str += f"- **{key}**: {value}\n"
return markdown_str
|