Spaces:
Running
Running
Commit
·
6d5de38
1
Parent(s):
5661288
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- .gitignore +0 -1
- .streamlit/config.toml +3 -0
- .streamlit/secrets.toml +25 -0
- app.py +35 -11
.gitignore
CHANGED
|
@@ -24,7 +24,6 @@ runs/
|
|
| 24 |
KP_Test/
|
| 25 |
|
| 26 |
# VV Specific
|
| 27 |
-
.streamlit*/
|
| 28 |
demo/demo_output/*
|
| 29 |
demo/validation_configs/*
|
| 30 |
/bin/*
|
|
|
|
| 24 |
KP_Test/
|
| 25 |
|
| 26 |
# VV Specific
|
|
|
|
| 27 |
demo/demo_output/*
|
| 28 |
demo/validation_configs/*
|
| 29 |
/bin/*
|
.streamlit/config.toml
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[theme]
|
| 2 |
+
base = "dark"
|
| 3 |
+
primaryColor = "#00ff00"
|
.streamlit/secrets.toml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Streamlit secrets
|
| 2 |
+
|
| 3 |
+
GOOGLE_APPLICATION_CREDENTIALS_JSON = '''
|
| 4 |
+
{
|
| 5 |
+
"type": "service_account",
|
| 6 |
+
"project_id": "directed-curve-401601",
|
| 7 |
+
"private_key_id": "53457e69bc362dd27bacb83228839a93c7361640",
|
| 8 |
+
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCnnRop1c/YAwQZ\nWuXJn9brvNUVJDuf+zmSuhZt9J3J4xnbeGDVrqJ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G/sX81\nfJ1r+1e0T9FrophKuG4I51wJi9N+i8vLQqPvxZCSgmx/hOPOdGLqSUrR8NguDOXh\nlXqs5Oe50EhjI1ZoAZaTBxZ62Sx0fQ99vRkDwGymE479QCQc2FYSR+iZAoGADRgH\nkDN8SudQxFlVCEhrZJrwzp0yyG1Z7dF3loG/j+j2oDB0mBrsQcFurM6+Mo+Vuuwt\nyr9AlDu9KKkHfnPFMy10WzFtNhJ3Z9f5X21L7PvYmXYXSHJmmXtxE5hQdm8KwGlf\n8kq2xppampDwsu19OkXXBg0sWqyBABRfdpUnAhECgYEAme0nq52gw9TbDqrfqQ/r\nT4NzjX7AaI0/oXekeW2Dm+NIx+umgggsx1/Hf3q5PWiy/x8ViTyoWYFdgaM72yCW\n9gVCTXkE/IHsTq9zX4khsv/UHTkHFf3VADCEjW+ht2nYeCBN1HwtLjdRidwvrSrC\nfL666ill9fXvSFnC4KsEfxE=\n-----END PRIVATE KEY-----\n",
|
| 9 |
+
"client_email": "[email protected]",
|
| 10 |
+
"client_id": "100706991621579323653",
|
| 11 |
+
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
| 12 |
+
"token_uri": "https://oauth2.googleapis.com/token",
|
| 13 |
+
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
| 14 |
+
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/vouchervision%40directed-curve-401601.iam.gserviceaccount.com",
|
| 15 |
+
"universe_domain": "googleapis.com"
|
| 16 |
+
}
|
| 17 |
+
'''
|
| 18 |
+
|
| 19 |
+
OPENAI_API_KEY = "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"
|
| 20 |
+
AZURE_API_VERSION = "2023-05-15"
|
| 21 |
+
AZURE_API_KEY = "2a841cc7fde64109975d84ea0f9685d4"
|
| 22 |
+
AZURE_API_BASE = "https://api.umgpt.umich.edu/azure-openai-api"
|
| 23 |
+
AZURE_ORGANIZATION = "123456"
|
| 24 |
+
AZURE_API_TYPE = "azure"
|
| 25 |
+
GOOGLE_PALM_API = "AIzaSyCiTxmzxi6vHih0jbAf8wtSX9_dBBXttKA"
|
app.py
CHANGED
|
@@ -71,7 +71,7 @@ def content_input_images_hf():
|
|
| 71 |
st.session_state.config['leafmachine']['project']['dir_images_local'] = st.session_state['dir_uploaded_images']
|
| 72 |
|
| 73 |
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))])
|
| 74 |
-
st.session_state['processing_add_on'] = f" {n_images}
|
| 75 |
uploaded_files = None
|
| 76 |
st.session_state['uploader_idk'] += 1
|
| 77 |
st.info(f"Processing **{n_images}** images from {st.session_state.config['leafmachine']['project']['dir_images_local']}")
|
|
@@ -96,13 +96,16 @@ def content_input_images_hf():
|
|
| 96 |
|
| 97 |
def create_download_button(zip_filepath, col):
|
| 98 |
with col:
|
|
|
|
| 99 |
with open(zip_filepath, 'rb') as f:
|
| 100 |
bytes_io = BytesIO(f.read())
|
| 101 |
st.download_button(
|
| 102 |
-
label=
|
|
|
|
| 103 |
data=bytes_io,
|
| 104 |
file_name=os.path.basename(zip_filepath),
|
| 105 |
-
mime='application/zip'
|
|
|
|
| 106 |
)
|
| 107 |
|
| 108 |
|
|
@@ -1375,14 +1378,27 @@ def show_header_welcome():
|
|
| 1375 |
|
| 1376 |
def determine_n_images():
|
| 1377 |
try:
|
| 1378 |
-
# Check if 'dir_uploaded_images' key exists and it is not empty
|
| 1379 |
-
if 'dir_uploaded_images' in st and st['dir_uploaded_images']:
|
| 1380 |
-
dir_path = st['dir_uploaded_images'] # This would be the path to the directory
|
| 1381 |
-
|
|
|
|
|
|
|
| 1382 |
else:
|
| 1383 |
-
return None
|
| 1384 |
-
except:
|
|
|
|
| 1385 |
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1386 |
|
| 1387 |
def save_api_status(present_keys, missing_keys, date_of_check):
|
| 1388 |
with open(os.path.join(st.session_state.dir_home,'api_status.yaml'), 'w') as file:
|
|
@@ -1566,8 +1582,9 @@ def content_header():
|
|
| 1566 |
# st.subheader('Run VoucherVision')
|
| 1567 |
N_STEPS = 6
|
| 1568 |
|
| 1569 |
-
|
| 1570 |
-
|
|
|
|
| 1571 |
else:
|
| 1572 |
st.session_state['processing_add_on'] = ''
|
| 1573 |
|
|
@@ -2360,7 +2377,14 @@ if 'json_report' not in st.session_state:
|
|
| 2360 |
if 'hold_output' not in st.session_state:
|
| 2361 |
st.session_state['hold_output'] = False
|
| 2362 |
|
|
|
|
|
|
|
|
|
|
| 2363 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2364 |
if 'cost_openai' not in st.session_state:
|
| 2365 |
st.session_state['cost_openai'] = None
|
| 2366 |
if 'cost_azure' not in st.session_state:
|
|
|
|
| 71 |
st.session_state.config['leafmachine']['project']['dir_images_local'] = st.session_state['dir_uploaded_images']
|
| 72 |
|
| 73 |
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))])
|
| 74 |
+
st.session_state['processing_add_on'] = f" {n_images} images"
|
| 75 |
uploaded_files = None
|
| 76 |
st.session_state['uploader_idk'] += 1
|
| 77 |
st.info(f"Processing **{n_images}** images from {st.session_state.config['leafmachine']['project']['dir_images_local']}")
|
|
|
|
| 96 |
|
| 97 |
def create_download_button(zip_filepath, col):
|
| 98 |
with col:
|
| 99 |
+
labale_n_images = f"Download Results for{st.session_state['processing_add_on']} Images"
|
| 100 |
with open(zip_filepath, 'rb') as f:
|
| 101 |
bytes_io = BytesIO(f.read())
|
| 102 |
st.download_button(
|
| 103 |
+
label=labale_n_images,
|
| 104 |
+
type='primary',
|
| 105 |
data=bytes_io,
|
| 106 |
file_name=os.path.basename(zip_filepath),
|
| 107 |
+
mime='application/zip',
|
| 108 |
+
use_container_width=True
|
| 109 |
)
|
| 110 |
|
| 111 |
|
|
|
|
| 1378 |
|
| 1379 |
def determine_n_images():
|
| 1380 |
try:
|
| 1381 |
+
# Check if 'dir_uploaded_images' key exists in session state and it is not empty
|
| 1382 |
+
if 'dir_uploaded_images' in st.session_state and st.session_state['dir_uploaded_images']:
|
| 1383 |
+
dir_path = st.session_state['dir_uploaded_images'] # This would be the path to the directory
|
| 1384 |
+
# Count only files (not directories) in the specified directory
|
| 1385 |
+
count = len([f for f in os.listdir(dir_path) if os.path.isfile(os.path.join(dir_path, f))])
|
| 1386 |
+
return count
|
| 1387 |
else:
|
| 1388 |
+
return None # Return 0 if the directory path doesn't exist or is empty
|
| 1389 |
+
except Exception as e:
|
| 1390 |
+
print(e)
|
| 1391 |
return None
|
| 1392 |
+
# def determine_n_images():
|
| 1393 |
+
# try:
|
| 1394 |
+
# # Check if 'dir_uploaded_images' key exists and it is not empty
|
| 1395 |
+
# if 'dir_uploaded_images' in st and st['dir_uploaded_images']:
|
| 1396 |
+
# dir_path = st['dir_uploaded_images'] # This would be the path to the directory
|
| 1397 |
+
# return len([f for f in os.listdir(dir_path) if os.path.isfile(os.path.join(dir_path, f))])
|
| 1398 |
+
# else:
|
| 1399 |
+
# return None
|
| 1400 |
+
# except:
|
| 1401 |
+
# return None
|
| 1402 |
|
| 1403 |
def save_api_status(present_keys, missing_keys, date_of_check):
|
| 1404 |
with open(os.path.join(st.session_state.dir_home,'api_status.yaml'), 'w') as file:
|
|
|
|
| 1582 |
# st.subheader('Run VoucherVision')
|
| 1583 |
N_STEPS = 6
|
| 1584 |
|
| 1585 |
+
count_n_imgs = determine_n_images()
|
| 1586 |
+
if count_n_imgs > 0:
|
| 1587 |
+
st.session_state['processing_add_on'] = f" {count_n_imgs} Images"
|
| 1588 |
else:
|
| 1589 |
st.session_state['processing_add_on'] = ''
|
| 1590 |
|
|
|
|
| 2377 |
if 'hold_output' not in st.session_state:
|
| 2378 |
st.session_state['hold_output'] = False
|
| 2379 |
|
| 2380 |
+
if 'dir_uploaded_images' not in st.session_state:
|
| 2381 |
+
st.session_state['dir_uploaded_images'] = os.path.join(st.session_state.dir_home,'uploads')
|
| 2382 |
+
validate_dir(os.path.join(st.session_state.dir_home,'uploads'))
|
| 2383 |
|
| 2384 |
+
if 'dir_uploaded_images_small' not in st.session_state:
|
| 2385 |
+
st.session_state['dir_uploaded_images_small'] = os.path.join(st.session_state.dir_home,'uploads_small')
|
| 2386 |
+
validate_dir(os.path.join(st.session_state.dir_home,'uploads_small'))
|
| 2387 |
+
|
| 2388 |
if 'cost_openai' not in st.session_state:
|
| 2389 |
st.session_state['cost_openai'] = None
|
| 2390 |
if 'cost_azure' not in st.session_state:
|