Spaces:
Running
Running
phyloforfun
commited on
Commit
•
8883473
1
Parent(s):
1f55e2a
refactor
Browse files
app.py
CHANGED
@@ -33,51 +33,12 @@ N_OVERALL_STEPS = 6
|
|
33 |
########################################################################################################
|
34 |
### Progress bar ####
|
35 |
########################################################################################################
|
36 |
-
# class ProgressReport:
|
37 |
-
# def __init__(self, overall_bar, batch_bar, text_overall, text_batch):
|
38 |
-
# self.overall_bar = overall_bar
|
39 |
-
# self.batch_bar = batch_bar
|
40 |
-
# self.text_overall = text_overall
|
41 |
-
# self.text_batch = text_batch
|
42 |
-
# self.current_overall_step = 0
|
43 |
-
# self.total_overall_steps = 20 # number of major steps in machine function
|
44 |
-
# self.current_batch = 0
|
45 |
-
# self.total_batches = 20
|
46 |
-
|
47 |
-
# def update_overall(self, step_name=""):
|
48 |
-
# self.current_overall_step += 1
|
49 |
-
# self.overall_bar.progress(self.current_overall_step / self.total_overall_steps)
|
50 |
-
# self.text_overall.text(step_name)
|
51 |
-
|
52 |
-
# def update_batch(self, step_name=""):
|
53 |
-
# self.current_batch += 1
|
54 |
-
# self.batch_bar.progress(self.current_batch / self.total_batches)
|
55 |
-
# self.text_batch.text(step_name)
|
56 |
-
|
57 |
-
# def set_n_batches(self, n_batches):
|
58 |
-
# self.total_batches = n_batches
|
59 |
-
|
60 |
-
# def set_n_overall(self, total_overall_steps):
|
61 |
-
# self.current_overall_step = 0
|
62 |
-
# self.overall_bar.progress(0)
|
63 |
-
# self.total_overall_steps = total_overall_steps
|
64 |
-
|
65 |
-
# def reset_batch(self, step_name):
|
66 |
-
# self.current_batch = 0
|
67 |
-
# self.batch_bar.progress(0)
|
68 |
-
# self.text_batch.text(step_name)
|
69 |
-
# def reset_overall(self, step_name):
|
70 |
-
# self.current_overall_step = 0
|
71 |
-
# self.overall_bar.progress(0)
|
72 |
-
# self.text_overall.text(step_name)
|
73 |
-
|
74 |
-
# def get_n_images(self):
|
75 |
-
# return self.n_images
|
76 |
-
# def get_n_overall(self):
|
77 |
-
# return self.total_overall_steps
|
78 |
class ProgressReport:
|
79 |
-
def __init__(self,
|
80 |
-
self.
|
|
|
|
|
|
|
81 |
self.current_overall_step = 0
|
82 |
self.total_overall_steps = 20 # number of major steps in machine function
|
83 |
self.current_batch = 0
|
@@ -85,29 +46,35 @@ class ProgressReport:
|
|
85 |
|
86 |
def update_overall(self, step_name=""):
|
87 |
self.current_overall_step += 1
|
88 |
-
|
89 |
-
self.
|
90 |
|
91 |
def update_batch(self, step_name=""):
|
92 |
self.current_batch += 1
|
93 |
-
|
94 |
-
self.
|
95 |
|
96 |
def set_n_batches(self, n_batches):
|
97 |
self.total_batches = n_batches
|
98 |
|
99 |
def set_n_overall(self, total_overall_steps):
|
100 |
self.current_overall_step = 0
|
101 |
-
self.
|
102 |
self.total_overall_steps = total_overall_steps
|
103 |
|
104 |
-
def reset_batch(self, step_name
|
105 |
self.current_batch = 0
|
106 |
-
self.
|
107 |
-
|
108 |
-
def reset_overall(self, step_name
|
109 |
self.current_overall_step = 0
|
110 |
-
self.
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
|
113 |
|
@@ -405,6 +372,7 @@ def btn_load_prompt(selected_yaml_file, dir_prompt):
|
|
405 |
|
406 |
|
407 |
def refresh():
|
|
|
408 |
st.write('')
|
409 |
|
410 |
|
@@ -423,8 +391,6 @@ def upload_local_prompt_to_server(dir_prompt):
|
|
423 |
st.success(f"Saved file {file_name} in {dir_prompt}")
|
424 |
else:
|
425 |
st.error("Please upload a .yaml file that you previously created using this Prompt Builder tool.")
|
426 |
-
st.session_state['uploader_idk'] += 1
|
427 |
-
st.rerun()
|
428 |
|
429 |
|
430 |
|
@@ -454,7 +420,7 @@ def use_test_image():
|
|
454 |
n_images = len([f for f in os.listdir(st.session_state.config['leafmachine']['project']['dir_images_local']) if os.path.isfile(os.path.join(st.session_state.config['leafmachine']['project']['dir_images_local'], f))])
|
455 |
st.session_state['processing_add_on'] = f" {n_images} Images"
|
456 |
clear_image_gallery()
|
457 |
-
|
458 |
|
459 |
|
460 |
|
@@ -990,53 +956,24 @@ The desired null value is also given. Populate the field with the null value of
|
|
990 |
}
|
991 |
st.json(st.session_state['prompt_info'])
|
992 |
|
993 |
-
# def content_header():
|
994 |
-
# # Header section, run, quick start, API report
|
995 |
-
# col_run_1, col_run_2, col_run_3, col_run_4 = st.columns([2,2,2,2])
|
996 |
-
|
997 |
-
# # Progress bar
|
998 |
-
# col_run_info_1 = st.columns([1])[0]
|
999 |
-
|
1000 |
-
# with col_run_info_1:
|
1001 |
-
# # Progress
|
1002 |
-
# st.subheader("Overall Progress")
|
1003 |
-
# overall_progress_bar = st.progress(0)
|
1004 |
-
# text_overall = st.empty() # Placeholder for current step name
|
1005 |
-
|
1006 |
-
# st.subheader('Transcription Progress')
|
1007 |
-
# batch_progress_bar = st.progress(0)
|
1008 |
-
# text_batch = st.empty() # Placeholder for current step name
|
1009 |
-
|
1010 |
-
# progress_report = ProgressReport(overall_progress_bar, batch_progress_bar, text_overall, text_batch)
|
1011 |
def content_header():
|
1012 |
# Header section, run, quick start, API report
|
1013 |
col_run_1, col_run_2, col_run_3, col_run_4 = st.columns([2,2,2,2])
|
1014 |
|
1015 |
-
# Progress bar
|
1016 |
col_run_info_1 = st.columns([1])[0]
|
1017 |
|
1018 |
with col_run_info_1:
|
1019 |
-
#
|
1020 |
st.subheader("Overall Progress")
|
1021 |
-
|
1022 |
text_overall = st.empty() # Placeholder for current step name
|
1023 |
|
1024 |
st.subheader('Transcription Progress')
|
1025 |
-
|
1026 |
text_batch = st.empty() # Placeholder for current step name
|
1027 |
|
1028 |
-
|
1029 |
-
def update_progress(overall_progress, batch_progress, overall_text, batch_text):
|
1030 |
-
if overall_progress is not None:
|
1031 |
-
overall_progress_bar = overall_progress_placeholder.progress(overall_progress)
|
1032 |
-
if batch_progress is not None:
|
1033 |
-
batch_progress_bar = batch_progress_placeholder.progress(batch_progress)
|
1034 |
-
if overall_text is not None:
|
1035 |
-
text_overall.text(overall_text)
|
1036 |
-
if batch_text is not None:
|
1037 |
-
text_batch.text(batch_text)
|
1038 |
-
|
1039 |
-
progress_report = ProgressReport(update_progress)
|
1040 |
|
1041 |
st.info("***Note:*** There is a known bug with tabs in Streamlit. If you update an input field it may take you back to the 'Project Settings' tab. Changes that you made are saved, it's just an annoying glitch. We are aware of this issue and will fix it as soon as we can.")
|
1042 |
st.write("If you use VoucherVision frequently, you can change the default values that are auto-populated in the form below. In a text editor or IDE, edit the first few rows in the file `../VoucherVision/vouchervision/VoucherVision_Config_Builder.py`")
|
@@ -1199,8 +1136,10 @@ def content_tab_settings():
|
|
1199 |
n_images = len([f for f in os.listdir(st.session_state.config['leafmachine']['project']['dir_images_local']) if os.path.isfile(os.path.join(st.session_state.config['leafmachine']['project']['dir_images_local'], f))])
|
1200 |
st.session_state['processing_add_on'] = f" {n_images} Images"
|
1201 |
uploaded_files = None
|
|
|
1202 |
st.info(f"Processing **{n_images}** images from {st.session_state.config['leafmachine']['project']['dir_images_local']}")
|
1203 |
|
|
|
1204 |
st.button("Use Test Image",help="This will clear any uploaded images and load the 1 provided test image.",on_click=use_test_image)
|
1205 |
|
1206 |
# Show uploaded images gallery (thumbnails only)
|
|
|
33 |
########################################################################################################
|
34 |
### Progress bar ####
|
35 |
########################################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
class ProgressReport:
|
37 |
+
def __init__(self, overall_bar, batch_bar, text_overall, text_batch):
|
38 |
+
self.overall_bar = overall_bar
|
39 |
+
self.batch_bar = batch_bar
|
40 |
+
self.text_overall = text_overall
|
41 |
+
self.text_batch = text_batch
|
42 |
self.current_overall_step = 0
|
43 |
self.total_overall_steps = 20 # number of major steps in machine function
|
44 |
self.current_batch = 0
|
|
|
46 |
|
47 |
def update_overall(self, step_name=""):
|
48 |
self.current_overall_step += 1
|
49 |
+
self.overall_bar.progress(self.current_overall_step / self.total_overall_steps)
|
50 |
+
self.text_overall.text(step_name)
|
51 |
|
52 |
def update_batch(self, step_name=""):
|
53 |
self.current_batch += 1
|
54 |
+
self.batch_bar.progress(self.current_batch / self.total_batches)
|
55 |
+
self.text_batch.text(step_name)
|
56 |
|
57 |
def set_n_batches(self, n_batches):
|
58 |
self.total_batches = n_batches
|
59 |
|
60 |
def set_n_overall(self, total_overall_steps):
|
61 |
self.current_overall_step = 0
|
62 |
+
self.overall_bar.progress(0)
|
63 |
self.total_overall_steps = total_overall_steps
|
64 |
|
65 |
+
def reset_batch(self, step_name):
|
66 |
self.current_batch = 0
|
67 |
+
self.batch_bar.progress(0)
|
68 |
+
self.text_batch.text(step_name)
|
69 |
+
def reset_overall(self, step_name):
|
70 |
self.current_overall_step = 0
|
71 |
+
self.overall_bar.progress(0)
|
72 |
+
self.text_overall.text(step_name)
|
73 |
+
|
74 |
+
def get_n_images(self):
|
75 |
+
return self.n_images
|
76 |
+
def get_n_overall(self):
|
77 |
+
return self.total_overall_steps
|
78 |
|
79 |
|
80 |
|
|
|
372 |
|
373 |
|
374 |
def refresh():
|
375 |
+
st.session_state['uploader_idk'] += 1
|
376 |
st.write('')
|
377 |
|
378 |
|
|
|
391 |
st.success(f"Saved file {file_name} in {dir_prompt}")
|
392 |
else:
|
393 |
st.error("Please upload a .yaml file that you previously created using this Prompt Builder tool.")
|
|
|
|
|
394 |
|
395 |
|
396 |
|
|
|
420 |
n_images = len([f for f in os.listdir(st.session_state.config['leafmachine']['project']['dir_images_local']) if os.path.isfile(os.path.join(st.session_state.config['leafmachine']['project']['dir_images_local'], f))])
|
421 |
st.session_state['processing_add_on'] = f" {n_images} Images"
|
422 |
clear_image_gallery()
|
423 |
+
st.session_state['uploader_idk'] += 1
|
424 |
|
425 |
|
426 |
|
|
|
956 |
}
|
957 |
st.json(st.session_state['prompt_info'])
|
958 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
959 |
def content_header():
|
960 |
# Header section, run, quick start, API report
|
961 |
col_run_1, col_run_2, col_run_3, col_run_4 = st.columns([2,2,2,2])
|
962 |
|
963 |
+
# Progress bar
|
964 |
col_run_info_1 = st.columns([1])[0]
|
965 |
|
966 |
with col_run_info_1:
|
967 |
+
# Progress
|
968 |
st.subheader("Overall Progress")
|
969 |
+
overall_progress_bar = st.progress(0)
|
970 |
text_overall = st.empty() # Placeholder for current step name
|
971 |
|
972 |
st.subheader('Transcription Progress')
|
973 |
+
batch_progress_bar = st.progress(0)
|
974 |
text_batch = st.empty() # Placeholder for current step name
|
975 |
|
976 |
+
progress_report = ProgressReport(overall_progress_bar, batch_progress_bar, text_overall, text_batch)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
977 |
|
978 |
st.info("***Note:*** There is a known bug with tabs in Streamlit. If you update an input field it may take you back to the 'Project Settings' tab. Changes that you made are saved, it's just an annoying glitch. We are aware of this issue and will fix it as soon as we can.")
|
979 |
st.write("If you use VoucherVision frequently, you can change the default values that are auto-populated in the form below. In a text editor or IDE, edit the first few rows in the file `../VoucherVision/vouchervision/VoucherVision_Config_Builder.py`")
|
|
|
1136 |
n_images = len([f for f in os.listdir(st.session_state.config['leafmachine']['project']['dir_images_local']) if os.path.isfile(os.path.join(st.session_state.config['leafmachine']['project']['dir_images_local'], f))])
|
1137 |
st.session_state['processing_add_on'] = f" {n_images} Images"
|
1138 |
uploaded_files = None
|
1139 |
+
st.session_state['uploader_idk'] += 1
|
1140 |
st.info(f"Processing **{n_images}** images from {st.session_state.config['leafmachine']['project']['dir_images_local']}")
|
1141 |
|
1142 |
+
|
1143 |
st.button("Use Test Image",help="This will clear any uploaded images and load the 1 provided test image.",on_click=use_test_image)
|
1144 |
|
1145 |
# Show uploaded images gallery (thumbnails only)
|