Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,4 @@
|
|
| 1 |
-
#import appStore.
|
| 2 |
-
#import appStore.netzero as netzero
|
| 3 |
-
#import appStore.sector as sector
|
| 4 |
-
#import appStore.adapmit as adapmit
|
| 5 |
-
#import appStore.ghg as ghg
|
| 6 |
-
#import appStore.policyaction as policyaction
|
| 7 |
-
#import appStore.conditional as conditional
|
| 8 |
-
#import appStore.indicator as indicator
|
| 9 |
import appStore.doc_processing as processing
|
| 10 |
from utils.uploadAndExample import add_upload
|
| 11 |
from PIL import Image
|
|
@@ -48,107 +41,49 @@ with st.expander("ℹ️ - About this app", expanded=False):
|
|
| 48 |
Place holder \
|
| 49 |
Place holder
|
| 50 |
""")
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
#st.image(image)
|
| 55 |
-
#with c3:
|
| 56 |
-
#st.write("""
|
| 57 |
-
# What happens in the background?
|
| 58 |
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
| 70 |
|
| 71 |
-
|
| 72 |
|
| 73 |
|
| 74 |
-
apps = [processing.app, target_extraction.app, netzero.app, ghg.app,
|
| 75 |
-
|
| 76 |
|
| 77 |
-
multiplier_val =1/len(apps)
|
| 78 |
-
if st.button("Analyze Document"):
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
|
| 84 |
|
| 85 |
-
if 'key1' in st.session_state:
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
|
| 99 |
-
#st.title("Identify references to vulnerable groups.")
|
| 100 |
|
| 101 |
-
#st.write("""Vulnerable groups encompass various communities and individuals who are disproportionately affected by the impacts of climate change
|
| 102 |
-
#due to their socioeconomic status, geographical location, or inherent characteristics. By incorporating the needs and perspectives of these groups
|
| 103 |
-
#into national climate policies, governments can ensure equitable outcomes, promote social justice, and strive to build resilience within the most marginalized populations,
|
| 104 |
-
#fostering a more sustainable and inclusive society as we navigate the challenges posed by climate change.This app allows you to identify whether a text contains any
|
| 105 |
-
#references to vulnerable groups, for example when talking about policy documents.""")
|
| 106 |
-
|
| 107 |
-
# Document upload
|
| 108 |
-
#uploaded_file = st.file_uploader("Upload your file here")
|
| 109 |
-
|
| 110 |
-
# Create text input box
|
| 111 |
-
#input_text = st.text_area(label='Please enter your text here', value="This policy has been implemented to support women.")
|
| 112 |
-
|
| 113 |
-
#st.write('Prediction:', model(input_text))
|
| 114 |
-
|
| 115 |
-
######################################### Model #########################################################
|
| 116 |
-
|
| 117 |
-
# Load the model
|
| 118 |
-
#model = SetFitModel.from_pretrained("leavoigt/vulnerable_groups")
|
| 119 |
-
|
| 120 |
-
# Define the classes
|
| 121 |
-
#id2label = {
|
| 122 |
-
# 0: 'Agricultural communities',
|
| 123 |
-
# 1: 'Children and Youth',
|
| 124 |
-
# 2: 'Coastal communities',
|
| 125 |
-
# 3: 'Drought-prone regions',
|
| 126 |
-
# 4: 'Economically disadvantaged communities',
|
| 127 |
-
# 5: 'Elderly population',
|
| 128 |
-
# 6: 'Ethnic minorities and indigenous people',
|
| 129 |
-
# 7: 'Informal sector workers',
|
| 130 |
-
# 8: 'Migrants and Refugees',
|
| 131 |
-
# 9: 'Other',
|
| 132 |
-
# 10: 'People with Disabilities',
|
| 133 |
-
# 11: 'Rural populations',
|
| 134 |
-
# 12: 'Sexual minorities (LGBTQI+)',
|
| 135 |
-
# 13: 'Urban populations',
|
| 136 |
-
# 14: 'Women'}
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
### Process document to paragraphs
|
| 140 |
-
# Source: https://blog.jcharistech.com/2021/01/21/how-to-save-uploaded-files-to-directory-in-streamlit-apps/
|
| 141 |
-
|
| 142 |
-
# Store uploaded file temporarily in directory to get file path (necessary for processing)
|
| 143 |
-
# def save_uploadedfile(upl_file):
|
| 144 |
-
# with open(os.path.join("tempDir",upl_file.name),"wb") as f:
|
| 145 |
-
# f.write(upl_file.getbuffer())
|
| 146 |
-
# return st.success("Saved File:{} to tempDir".format(upl_file.name))
|
| 147 |
-
|
| 148 |
-
# if uploaded_file is not None:
|
| 149 |
-
# # Save the file
|
| 150 |
-
# file_details = {"FileName": uploaded_file.name, "FileType": uploaded_file.type}
|
| 151 |
-
# save_uploadedfile(uploaded_file)
|
| 152 |
-
|
| 153 |
-
# #Get the file path
|
| 154 |
|
|
|
|
| 1 |
+
#import appStore.identifier as target_identifier
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import appStore.doc_processing as processing
|
| 3 |
from utils.uploadAndExample import add_upload
|
| 4 |
from PIL import Image
|
|
|
|
| 41 |
Place holder \
|
| 42 |
Place holder
|
| 43 |
""")
|
| 44 |
+
|
| 45 |
+
st.write("""
|
| 46 |
+
What happens in the background?
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
- Step 1: Once the document is provided to app, it undergoes *Pre-processing*.\
|
| 49 |
+
In this step the document is broken into smaller paragraphs \
|
| 50 |
+
(based on word/sentence count).
|
| 51 |
+
- Step 2: The paragraphs are fed to **Target Classifier** which detects if
|
| 52 |
+
the paragraph contains any *Target* related information or not.
|
| 53 |
+
- Step 3: The paragraphs which are detected containing some target \
|
| 54 |
+
related information are then fed to multiple classifier to enrich the
|
| 55 |
+
Information Extraction.
|
| 56 |
|
| 57 |
+
The Step 2 and 3 are repated then similarly for Action and Policies & Plans.
|
| 58 |
+
""")
|
| 59 |
|
| 60 |
+
st.write("")
|
| 61 |
|
| 62 |
|
| 63 |
+
# apps = [processing.app, target_extraction.app, netzero.app, ghg.app,
|
| 64 |
+
# policyaction.app, conditional.app, sector.app, adapmit.app,indicator.app]
|
| 65 |
|
| 66 |
+
# multiplier_val =1/len(apps)
|
| 67 |
+
# if st.button("Analyze Document"):
|
| 68 |
+
# prg = st.progress(0.0)
|
| 69 |
+
# for i,func in enumerate(apps):
|
| 70 |
+
# func()
|
| 71 |
+
# prg.progress((i+1)*multiplier_val)
|
| 72 |
|
| 73 |
|
| 74 |
+
# if 'key1' in st.session_state:
|
| 75 |
+
# with st.sidebar:
|
| 76 |
+
# topic = st.radio(
|
| 77 |
+
# "Which category you want to explore?",
|
| 78 |
+
# ('Target', 'Action', 'Policies/Plans'))
|
| 79 |
|
| 80 |
+
# if topic == 'Target':
|
| 81 |
+
# target_extraction.target_display()
|
| 82 |
+
# elif topic == 'Action':
|
| 83 |
+
# policyaction.action_display()
|
| 84 |
+
# else:
|
| 85 |
+
# policyaction.policy_display()
|
| 86 |
+
# # st.write(st.session_state.key1)
|
| 87 |
|
|
|
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|