Spaces:
Runtime error
Runtime error
Undo caching and display image with caption
Browse files
app.py
CHANGED
@@ -19,7 +19,6 @@ def save_file_to_disk(uplaoded_file):
|
|
19 |
f.write(uploaded_file.getbuffer())
|
20 |
return temp_file
|
21 |
|
22 |
-
@st.cache
|
23 |
def load_tokenizer_and_model():
|
24 |
# load the saved model
|
25 |
tokenizer = AutoTokenizer.from_pretrained("dccuchile/bert-base-spanish-wwm-cased")
|
@@ -36,8 +35,9 @@ if uploaded_file is not None and text_input:
|
|
36 |
local_image_path = None
|
37 |
try:
|
38 |
local_image_path = save_file_to_disk(uploaded_file)
|
39 |
-
score = run_inference(local_image_path, text_input, model, tokenizer)
|
40 |
-
st.
|
|
|
41 |
finally:
|
42 |
if local_image_path:
|
43 |
os.remove(local_image_path)
|
|
|
19 |
f.write(uploaded_file.getbuffer())
|
20 |
return temp_file
|
21 |
|
|
|
22 |
def load_tokenizer_and_model():
|
23 |
# load the saved model
|
24 |
tokenizer = AutoTokenizer.from_pretrained("dccuchile/bert-base-spanish-wwm-cased")
|
|
|
35 |
local_image_path = None
|
36 |
try:
|
37 |
local_image_path = save_file_to_disk(uploaded_file)
|
38 |
+
score = run_inference(local_image_path, text_input, model, tokenizer).tolist()
|
39 |
+
st.image(uploaded_file, caption=text_input, width=None, use_column_width=None, clamp=False, channels='RGB', output_format='auto')
|
40 |
+
st.write(f"## Score: {score:.2f}")
|
41 |
finally:
|
42 |
if local_image_path:
|
43 |
os.remove(local_image_path)
|