Spaces:
Running
Running
Commit
•
5efd4b8
1
Parent(s):
945eeae
file upload gallery
Browse files- app.py +12 -2
- requirements.txt +2 -1
app.py
CHANGED
@@ -10,6 +10,7 @@ import pandas as pd
|
|
10 |
from typing import Union
|
11 |
from google.oauth2 import service_account
|
12 |
from streamlit_extras.let_it_rain import rain
|
|
|
13 |
from vouchervision.LeafMachine2_Config_Builder import write_config_file
|
14 |
from vouchervision.VoucherVision_Config_Builder import build_VV_config, run_demo_tests_GPT, run_demo_tests_Palm , TestOptionsGPT, TestOptionsPalm, check_if_usable, run_api_tests
|
15 |
from vouchervision.vouchervision_main import voucher_vision, voucher_vision_OCR_test
|
@@ -287,7 +288,7 @@ def save_uploaded_file(directory, img_file):
|
|
287 |
def delete_directory(dir_path):
|
288 |
try:
|
289 |
shutil.rmtree(dir_path)
|
290 |
-
st.success(f"Deleted
|
291 |
except OSError as e:
|
292 |
st.error(f"Error: {dir_path} : {e.strerror}")
|
293 |
|
@@ -1046,7 +1047,7 @@ def content_tab_settings():
|
|
1046 |
|
1047 |
st.write("---")
|
1048 |
st.header('Input Images')
|
1049 |
-
col_local_1, col_local_2 = st.columns([4,2])
|
1050 |
|
1051 |
# st.write("---")
|
1052 |
# st.header('Modules')
|
@@ -1089,12 +1090,21 @@ def content_tab_settings():
|
|
1089 |
st.session_state['dir_uploaded_images'] = os.path.join(st.session_state.dir_home,'uploads')
|
1090 |
uploaded_files = st.file_uploader("Upload Images", type=['jpg', 'jpeg'], accept_multiple_files=True)
|
1091 |
if uploaded_files:
|
|
|
1092 |
delete_directory(st.session_state['dir_uploaded_images'])
|
|
|
1093 |
st.session_state['dir_uploaded_images'] = os.path.join(st.session_state.dir_home,'uploads')
|
1094 |
validate_dir(st.session_state['dir_uploaded_images'])
|
|
|
|
|
1095 |
for uploaded_file in uploaded_files:
|
1096 |
print(uploaded_file)
|
|
|
1097 |
save_uploaded_file(st.session_state['dir_uploaded_images'], uploaded_file)
|
|
|
|
|
|
|
|
|
1098 |
|
1099 |
with col_cropped_1:
|
1100 |
default_crops = st.session_state.config['leafmachine']['cropped_components'].get('save_cropped_annotations', ['leaf_whole'])
|
|
|
10 |
from typing import Union
|
11 |
from google.oauth2 import service_account
|
12 |
from streamlit_extras.let_it_rain import rain
|
13 |
+
from streamlit_image_select import image_select
|
14 |
from vouchervision.LeafMachine2_Config_Builder import write_config_file
|
15 |
from vouchervision.VoucherVision_Config_Builder import build_VV_config, run_demo_tests_GPT, run_demo_tests_Palm , TestOptionsGPT, TestOptionsPalm, check_if_usable, run_api_tests
|
16 |
from vouchervision.vouchervision_main import voucher_vision, voucher_vision_OCR_test
|
|
|
288 |
def delete_directory(dir_path):
|
289 |
try:
|
290 |
shutil.rmtree(dir_path)
|
291 |
+
st.success(f"Deleted previously uploaded images, making room for new images: {dir_path}")
|
292 |
except OSError as e:
|
293 |
st.error(f"Error: {dir_path} : {e.strerror}")
|
294 |
|
|
|
1047 |
|
1048 |
st.write("---")
|
1049 |
st.header('Input Images')
|
1050 |
+
col_local_1, col_local_2, col_local_3 = st.columns([4,2,4])
|
1051 |
|
1052 |
# st.write("---")
|
1053 |
# st.header('Modules')
|
|
|
1090 |
st.session_state['dir_uploaded_images'] = os.path.join(st.session_state.dir_home,'uploads')
|
1091 |
uploaded_files = st.file_uploader("Upload Images", type=['jpg', 'jpeg'], accept_multiple_files=True)
|
1092 |
if uploaded_files:
|
1093 |
+
# Clear input image gallery and input list
|
1094 |
delete_directory(st.session_state['dir_uploaded_images'])
|
1095 |
+
st.session_state['input_list'] = []
|
1096 |
st.session_state['dir_uploaded_images'] = os.path.join(st.session_state.dir_home,'uploads')
|
1097 |
validate_dir(st.session_state['dir_uploaded_images'])
|
1098 |
+
|
1099 |
+
# Process the new iamges
|
1100 |
for uploaded_file in uploaded_files:
|
1101 |
print(uploaded_file)
|
1102 |
+
st.session_state['input_list'].appened(os.path.join(st.session_state.dir_home,'uploads',uploaded_file))
|
1103 |
save_uploaded_file(st.session_state['dir_uploaded_images'], uploaded_file)
|
1104 |
+
|
1105 |
+
with col_local_3:
|
1106 |
+
selected_img = image_select("Uploaded Images Ready for Transcription", st.session_state['input_list'], use_container_width=False)
|
1107 |
+
st.button("Clear Staged Images",on_click=delete_directory, args=[st.session_state['dir_uploaded_images']])
|
1108 |
|
1109 |
with col_cropped_1:
|
1110 |
default_crops = st.session_state.config['leafmachine']['cropped_components'].get('save_cropped_annotations', ['leaf_whole'])
|
requirements.txt
CHANGED
@@ -32,4 +32,5 @@ dask
|
|
32 |
psutil
|
33 |
py-cpuinfo
|
34 |
azureml-sdk
|
35 |
-
azure-identity
|
|
|
|
32 |
psutil
|
33 |
py-cpuinfo
|
34 |
azureml-sdk
|
35 |
+
azure-identity
|
36 |
+
streamlit-image-select
|