Javi commited on
Commit
de38ce1
·
1 Parent(s): ed1918f

Simple progress bar

Browse files
Files changed (1) hide show
  1. streamlit_app.py +14 -4
streamlit_app.py CHANGED
@@ -64,11 +64,21 @@ with col2:
64
  if st.button("Predict"):
65
  with st.spinner("Predicting..."):
66
  clip_response = booste.clip(BOOSTE_API_KEY,
67
- prompts=input_prompts,
68
- images=[session_state.image],
69
- pretty_print=True)
70
- st.write(clip_response)
 
 
 
 
 
71
 
 
 
 
 
 
72
 
73
  session_state.sync()
74
 
 
64
  if st.button("Predict"):
65
  with st.spinner("Predicting..."):
66
  clip_response = booste.clip(BOOSTE_API_KEY,
67
+ prompts=input_prompts,
68
+ images=[session_state.image],
69
+ pretty_print=True)
70
+ st.markdown("### Results")
71
+ simplified_clip_results = [(prompt[len('A picture of a '):],
72
+ list(results.values())[0]["probabilityRelativeToPrompts"])
73
+ for prompt, results in clip_response.items()]
74
+ simplified_clip_results = sorted(simplified_clip_results, key=lambda x: x[1], reverse=True)
75
+ max_class_name_length = max(len(class_name) for class_name, _ in simplified_clip_results)
76
 
77
+ for prompt, probability in simplified_clip_results:
78
+ progress_bar = "".join([":large_blue_circle:"] * int(probability * 10) +
79
+ [":black_circle:"] * int((1 - probability) * 10))
80
+ st.markdown(f"### {prompt}: {progress_bar} {probability:.3f}")
81
+ st.write(clip_response)
82
 
83
  session_state.sync()
84