當前位置: 首頁>>代碼示例>>Python>>正文


Python streamlit.subheader方法代碼示例

本文整理匯總了Python中streamlit.subheader方法的典型用法代碼示例。如果您正苦於以下問題:Python streamlit.subheader方法的具體用法?Python streamlit.subheader怎麽用?Python streamlit.subheader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在streamlit的用法示例。


在下文中一共展示了streamlit.subheader方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: draw_image_with_boxes

# 需要導入模塊: import streamlit [as 別名]
# 或者: from streamlit import subheader [as 別名]
def draw_image_with_boxes(image, boxes, header, description):
    # Superpose the semi-transparent object detection boxes.    # Colors for the boxes
    LABEL_COLORS = {
        "car": [255, 0, 0],
        "pedestrian": [0, 255, 0],
        "truck": [0, 0, 255],
        "trafficLight": [255, 255, 0],
        "biker": [255, 0, 255],
    }
    image_with_boxes = image.astype(np.float64)
    for _, (xmin, ymin, xmax, ymax, label) in boxes.iterrows():
        image_with_boxes[int(ymin):int(ymax),int(xmin):int(xmax),:] += LABEL_COLORS[label]
        image_with_boxes[int(ymin):int(ymax),int(xmin):int(xmax),:] /= 2

    # Draw the header and image.
    st.subheader(header)
    st.markdown(description)
    st.image(image_with_boxes.astype(np.uint8), use_column_width=True)

# Download a single file and make its content available as a string. 
開發者ID:streamlit,項目名稱:demo-self-driving,代碼行數:22,代碼來源:app.py

示例2: st_lime_explanation

# 需要導入模塊: import streamlit [as 別名]
# 或者: from streamlit import subheader [as 別名]
def st_lime_explanation(
    text: str,
    predict_func: Callable[[List[str]], np.ndarray],
    unique_labels: List[str],
    n_samples: int,
    position_dependent: bool = True,
):
    # TODO just use ELI5's built-in visualization when streamlit supports it:
    # https://github.com/streamlit/streamlit/issues/779
    with st.spinner("Generating LIME explanations..."):
        te = TextExplainer(
            random_state=1, n_samples=n_samples, position_dependent=position_dependent
        )
        te.fit(text, predict_func)
    st.json(te.metrics_)
    explanation = te.explain_prediction()
    explanation_df = eli5.format_as_dataframe(explanation)
    for target_ndx, target in enumerate(
        sorted(explanation.targets, key=lambda t: -t.proba)
    ):
        target_explanation_df = explanation_df[
            explanation_df["target"] == target_ndx
        ].copy()

        target_explanation_df["contribution"] = (
            target_explanation_df["weight"] * target_explanation_df["value"]
        )
        target_explanation_df["abs_contribution"] = abs(
            target_explanation_df["contribution"]
        )
        target_explanation_df = (
            target_explanation_df.drop("target", axis=1)
            .sort_values(by="abs_contribution", ascending=False)
            .reset_index(drop=True)
        )
        st.subheader(
            f"Target: {unique_labels[target_ndx]} (probability {target.proba:.4f}, score {target.score:.4f})"
        )
        st.dataframe(target_explanation_df) 
開發者ID:RTIInternational,項目名稱:gobbli,代碼行數:41,代碼來源:explain.py

示例3: show_example_documents

# 需要導入模塊: import streamlit [as 別名]
# 或者: from streamlit import subheader [as 別名]
def show_example_documents(
    texts: List[str],
    labels: Union[List[str], List[List[str]]],
    filter_label: Optional[str],
    example_truncate_len: int,
    example_num_docs: int,
):
    st.header("Example Documents")

    # If we're filtered to a specific label,
    # just show it once at the top -- otherwise, show the label
    # with each example
    if filter_label is not None:
        st.subheader(f"Label: {filter_label}")
        example_labels = None
    else:
        example_labels = labels

    example_indices = safe_sample(range(len(texts)), example_num_docs)
    _show_example_documents(
        [texts[i] for i in example_indices],
        [example_labels[i] for i in example_indices]
        if example_labels is not None
        else None,
        example_truncate_len,
    ) 
開發者ID:RTIInternational,項目名稱:gobbli,代碼行數:28,代碼來源:explore.py


注:本文中的streamlit.subheader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。