Spaces:
Running
Running
phyloforfun
commited on
Commit
•
e805b05
1
Parent(s):
3b75f1a
file upload gallery
Browse files- app.py +30 -1
- requirements.txt +2 -1
app.py
CHANGED
@@ -11,7 +11,9 @@ import pandas as pd
|
|
11 |
from typing import Union
|
12 |
from google.oauth2 import service_account
|
13 |
from streamlit_extras.let_it_rain import rain
|
14 |
-
from
|
|
|
|
|
15 |
from vouchervision.LeafMachine2_Config_Builder import write_config_file
|
16 |
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
|
17 |
from vouchervision.vouchervision_main import voucher_vision, voucher_vision_OCR_test
|
@@ -704,10 +706,37 @@ def save_prompt_yaml(filename, col_right_save):
|
|
704 |
yaml.safe_dump(yaml_content, file)
|
705 |
|
706 |
st.success(f"Prompt saved as '{filename}.yaml'.")
|
|
|
|
|
707 |
|
708 |
with col_right_save:
|
709 |
create_download_button(filepath, filename)
|
710 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
711 |
def check_unique_mapping_assignments():
|
712 |
if len(st.session_state['assigned_columns']) != len(set(st.session_state['assigned_columns'])):
|
713 |
st.error("Each column name must be assigned to only one category.")
|
|
|
11 |
from typing import Union
|
12 |
from google.oauth2 import service_account
|
13 |
from streamlit_extras.let_it_rain import rain
|
14 |
+
from google.oauth2 import service_account
|
15 |
+
from googleapiclient.discovery import build
|
16 |
+
from googleapiclient.http import MediaFileUpload
|
17 |
from vouchervision.LeafMachine2_Config_Builder import write_config_file
|
18 |
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
|
19 |
from vouchervision.vouchervision_main import voucher_vision, voucher_vision_OCR_test
|
|
|
706 |
yaml.safe_dump(yaml_content, file)
|
707 |
|
708 |
st.success(f"Prompt saved as '{filename}.yaml'.")
|
709 |
+
|
710 |
+
upload_to_drive(filepath, filename)
|
711 |
|
712 |
with col_right_save:
|
713 |
create_download_button(filepath, filename)
|
714 |
|
715 |
+
# Function to upload files to Google Drive
|
716 |
+
def upload_to_drive(filepath, filename):
|
717 |
+
# Parse the service account info from the environment variable
|
718 |
+
creds_info = json.loads(os.environ.get('GDRIVE_API'))
|
719 |
+
creds = service_account.Credentials.from_service_account_info(
|
720 |
+
creds_info, scopes=["https://www.googleapis.com/auth/drive"]
|
721 |
+
)
|
722 |
+
service = build('drive', 'v3', credentials=creds)
|
723 |
+
|
724 |
+
# Get the folder ID from the environment variable
|
725 |
+
folder_id = os.environ.get('GDRIVE_FOLDER_ID')
|
726 |
+
|
727 |
+
file_metadata = {
|
728 |
+
'name': filename,
|
729 |
+
'parents': [folder_id]
|
730 |
+
}
|
731 |
+
|
732 |
+
media = MediaFileUpload(filepath, mimetype='application/x-yaml')
|
733 |
+
|
734 |
+
service.files().create(
|
735 |
+
body=file_metadata,
|
736 |
+
media_body=media,
|
737 |
+
fields='id'
|
738 |
+
).execute()
|
739 |
+
|
740 |
def check_unique_mapping_assignments():
|
741 |
if len(st.session_state['assigned_columns']) != len(set(st.session_state['assigned_columns'])):
|
742 |
st.error("Each column name must be assigned to only one category.")
|
requirements.txt
CHANGED
@@ -21,6 +21,7 @@ openpyxl
|
|
21 |
google-generativeai
|
22 |
google-cloud-storage
|
23 |
google-cloud-vision
|
|
|
24 |
opencv-python
|
25 |
chromadb
|
26 |
chroma-migrate
|
@@ -33,4 +34,4 @@ psutil
|
|
33 |
py-cpuinfo
|
34 |
azureml-sdk
|
35 |
azure-identity
|
36 |
-
|
|
|
21 |
google-generativeai
|
22 |
google-cloud-storage
|
23 |
google-cloud-vision
|
24 |
+
google-api-python-client
|
25 |
opencv-python
|
26 |
chromadb
|
27 |
chroma-migrate
|
|
|
34 |
py-cpuinfo
|
35 |
azureml-sdk
|
36 |
azure-identity
|
37 |
+
|