phyloforfun commited on
Commit
4d14f52
1 Parent(s): b8abf64

Major update. Support for 15 LLMs, World Flora Online taxonomy validation, geolocation, 2 OCR methods, significant UI changes, stability improvements, consistent JSON parsing

Browse files
Files changed (1) hide show
  1. app.py +27 -27
app.py CHANGED
@@ -242,14 +242,14 @@ def use_test_image():
242
  st.session_state['input_list_small'].append(file_path_small)
243
 
244
 
245
- def create_download_button_yaml(file_path, selected_yaml_file):
246
  file_label = f"Download {selected_yaml_file}"
247
  with open(file_path, 'rb') as f:
248
  st.download_button(
249
  label=file_label,
250
  data=f,
251
  file_name=os.path.basename(file_path),
252
- mime='application/x-yaml',use_container_width=True,key=237895,
253
  )
254
 
255
 
@@ -1015,7 +1015,7 @@ def save_prompt_yaml(filename, col):
1015
  upload_to_drive(filepath, filename) # added
1016
 
1017
  with col: # added
1018
- create_download_button_yaml(filepath, filename) # added
1019
 
1020
  def check_unique_mapping_assignments():
1021
  print(st.session_state['assigned_columns'])
@@ -1147,7 +1147,7 @@ def build_LLM_prompt_config():
1147
  download_file_path = os.path.join(dir_prompt, st.session_state['selected_yaml_file'] )
1148
  # Create the download button
1149
  st.write('##')
1150
- create_download_button_yaml(download_file_path, st.session_state['selected_yaml_file'] )
1151
 
1152
  # Prompt Author Information
1153
  st.write("---")
@@ -1435,23 +1435,23 @@ def build_LLM_prompt_config():
1435
 
1436
 
1437
 
1438
- st.write('---')
1439
- st.header("Save and Download Custom Prompt")
1440
- st.write('Once you click save, validation checks will verify the formatting and then a download button will appear so that you can ***save a local copy of your custom prompt.***')
1441
- col_left_save, col_right_save, _ = st.columns([2,2,8])
1442
- with col_left_save:
1443
- # Button to save the new YAML file
1444
- if st.button('Save YAML', type='primary',key=3450798):
1445
- if st.session_state['prompt_name']:
1446
- if check_unique_mapping_assignments():
1447
- if check_prompt_yaml_filename(st.session_state['prompt_name']):
1448
- save_prompt_yaml(st.session_state['prompt_name'], col_right_save)
1449
- else:
1450
- st.error("File name can only contain letters, numbers, underscores, and dashes. Cannot contain spaces.")
1451
- else:
1452
- st.error("Mapping contains an error. Make sure that each column is assigned to only ***one*** category.")
1453
- else:
1454
- st.error("Please enter a filename.")
1455
 
1456
  # with col_prompt_main_right:
1457
  # st.subheader('All Prompt Components')
@@ -1751,6 +1751,7 @@ def content_header():
1751
  path_api_cost=os.path.join(st.session_state.dir_home,'api_cost','api_cost.yaml'),
1752
  is_hf = st.session_state['is_hf'],
1753
  is_real_run=True)
 
1754
  except Exception as e:
1755
  with col_run_4:
1756
  st.error(f"Transcription failed. Error: {e}")
@@ -1770,7 +1771,6 @@ def content_header():
1770
  else:
1771
  with col_run_4:
1772
  st.info(f":money_with_wings: This run cost :heavy_dollar_sign:{total_cost:.4f}")
1773
- st.balloons()
1774
  if st.session_state['zip_filepath']:
1775
  create_download_button(st.session_state['zip_filepath'], col_run_1)
1776
  else:
@@ -2089,7 +2089,7 @@ def content_collage_overlay():
2089
  raise
2090
 
2091
  st.write("Supplement Google Vision OCR with trOCR (handwriting OCR) using `microsoft/trocr-base-handwritten`. This option requires Google Vision API and a GPU.")
2092
- do_use_trOCR = st.checkbox("Enable trOCR", value=st.session_state.config['leafmachine']['project']['do_use_trOCR'],disabled=st.session_state['lacks_GPU'])
2093
  st.session_state.config['leafmachine']['project']['do_use_trOCR'] = do_use_trOCR
2094
 
2095
 
@@ -2407,13 +2407,13 @@ def main():
2407
  content_prompt_and_llm_version()
2408
  with col4:
2409
  content_api_check()
2410
- content_llm_cost()
2411
  content_collage_overlay()
 
2412
  content_processing_options()
2413
  content_less_used()
2414
- content_archival_components()
2415
- content_space_saver()
2416
- # content_tab_domain()
2417
 
2418
 
2419
 
 
242
  st.session_state['input_list_small'].append(file_path_small)
243
 
244
 
245
+ def create_download_button_yaml(file_path, selected_yaml_file, key_val):
246
  file_label = f"Download {selected_yaml_file}"
247
  with open(file_path, 'rb') as f:
248
  st.download_button(
249
  label=file_label,
250
  data=f,
251
  file_name=os.path.basename(file_path),
252
+ mime='application/x-yaml',use_container_width=True,key=key_val,
253
  )
254
 
255
 
 
1015
  upload_to_drive(filepath, filename) # added
1016
 
1017
  with col: # added
1018
+ create_download_button_yaml(filepath, filename,key_val=2456237465) # added
1019
 
1020
  def check_unique_mapping_assignments():
1021
  print(st.session_state['assigned_columns'])
 
1147
  download_file_path = os.path.join(dir_prompt, st.session_state['selected_yaml_file'] )
1148
  # Create the download button
1149
  st.write('##')
1150
+ create_download_button_yaml(download_file_path, st.session_state['selected_yaml_file'],key_val=345798)
1151
 
1152
  # Prompt Author Information
1153
  st.write("---")
 
1435
 
1436
 
1437
 
1438
+ # st.write('---')
1439
+ # st.header("Save and Download Custom Prompt")
1440
+ # st.write('Once you click save, validation checks will verify the formatting and then a download button will appear so that you can ***save a local copy of your custom prompt.***')
1441
+ # col_left_save, col_right_save, _ = st.columns([2,2,8])
1442
+ # with col_left_save:
1443
+ # # Button to save the new YAML file
1444
+ # if st.button('Save YAML', type='primary',key=3450798):
1445
+ # if st.session_state['prompt_name']:
1446
+ # if check_unique_mapping_assignments():
1447
+ # if check_prompt_yaml_filename(st.session_state['prompt_name']):
1448
+ # save_prompt_yaml(st.session_state['prompt_name'], col_right_save)
1449
+ # else:
1450
+ # st.error("File name can only contain letters, numbers, underscores, and dashes. Cannot contain spaces.")
1451
+ # else:
1452
+ # st.error("Mapping contains an error. Make sure that each column is assigned to only ***one*** category.")
1453
+ # else:
1454
+ # st.error("Please enter a filename.")
1455
 
1456
  # with col_prompt_main_right:
1457
  # st.subheader('All Prompt Components')
 
1751
  path_api_cost=os.path.join(st.session_state.dir_home,'api_cost','api_cost.yaml'),
1752
  is_hf = st.session_state['is_hf'],
1753
  is_real_run=True)
1754
+ st.balloons()
1755
  except Exception as e:
1756
  with col_run_4:
1757
  st.error(f"Transcription failed. Error: {e}")
 
1771
  else:
1772
  with col_run_4:
1773
  st.info(f":money_with_wings: This run cost :heavy_dollar_sign:{total_cost:.4f}")
 
1774
  if st.session_state['zip_filepath']:
1775
  create_download_button(st.session_state['zip_filepath'], col_run_1)
1776
  else:
 
2089
  raise
2090
 
2091
  st.write("Supplement Google Vision OCR with trOCR (handwriting OCR) using `microsoft/trocr-base-handwritten`. This option requires Google Vision API and a GPU.")
2092
+ do_use_trOCR = st.checkbox("Enable trOCR", value=st.session_state.config['leafmachine']['project']['do_use_trOCR'])#,disabled=st.session_state['lacks_GPU'])
2093
  st.session_state.config['leafmachine']['project']['do_use_trOCR'] = do_use_trOCR
2094
 
2095
 
 
2407
  content_prompt_and_llm_version()
2408
  with col4:
2409
  content_api_check()
 
2410
  content_collage_overlay()
2411
+ content_llm_cost()
2412
  content_processing_options()
2413
  content_less_used()
2414
+ with st.expander("View additional settings"):
2415
+ content_archival_components()
2416
+ content_space_saver()
2417
 
2418
 
2419