gchhablani commited on
Commit
42dfeae
1 Parent(s): 82b495f

Allow clearing of cache

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -4,7 +4,7 @@ import pandas as pd
4
  import json
5
  import os
6
  import numpy as np
7
- from streamlit.elements import markdown
8
  from PIL import Image
9
  from model.flax_clip_vision_mbart.modeling_clip_vision_mbart import (
10
  FlaxCLIPVisionMBartForConditionalGeneration,
@@ -110,9 +110,9 @@ if state.image_file is None:
110
  image = plt.imread(image_path)
111
  state.image = image
112
 
113
- # col1, col2 = st.beta_columns([6, 4])
114
 
115
- if st.button("Get a random example", help="Get a random example from one of the seeded examples."):
116
  sample = dummy_data.sample(1).reset_index()
117
  state.image_file = sample.loc[0, "image_file"]
118
  state.caption = sample.loc[0, "caption"].strip("- ")
@@ -122,7 +122,8 @@ if st.button("Get a random example", help="Get a random example from one of the
122
  image = plt.imread(image_path)
123
  state.image = image
124
 
125
- # col2.write("OR")
 
126
 
127
  # uploaded_file = col2.file_uploader("Upload your image", type=["png", "jpg", "jpeg"])
128
  # if uploaded_file is not None:
 
4
  import json
5
  import os
6
  import numpy as np
7
+ from streamlit import caching
8
  from PIL import Image
9
  from model.flax_clip_vision_mbart.modeling_clip_vision_mbart import (
10
  FlaxCLIPVisionMBartForConditionalGeneration,
 
110
  image = plt.imread(image_path)
111
  state.image = image
112
 
113
+ col1, col2 = st.beta_columns([5, 5])
114
 
115
+ if col1.button("Get a random example", help="Get a random example from one of the seeded examples."):
116
  sample = dummy_data.sample(1).reset_index()
117
  state.image_file = sample.loc[0, "image_file"]
118
  state.caption = sample.loc[0, "caption"].strip("- ")
 
122
  image = plt.imread(image_path)
123
  state.image = image
124
 
125
+ if col2.sidebar.button("Clear All Cache"):
126
+ caching.clear_cache()
127
 
128
  # uploaded_file = col2.file_uploader("Upload your image", type=["png", "jpg", "jpeg"])
129
  # if uploaded_file is not None: