Tinsae commited on
Commit
0d8c862
β€’
1 Parent(s): 1127294

working app

Browse files
app.py CHANGED
@@ -1,37 +1,26 @@
1
  import streamlit as st
2
- from streamlit_option_menu import option_menu
3
  from PIL import Image
4
 
5
- from apps import home, dashboard, models,demo
6
 
7
- #st.set_page_config(layout="wide")
8
  image = Image.open('data/logo.png')
9
  image=image.resize((100,100))
10
- header = st.container()
 
 
 
11
 
12
- apps = [
13
- {"func": home.app, "title": "Home", "icon": "house"},
14
- {"func": dashboard.app, "title": "Dashboard", "icon": "bar-chart"},
15
- {"func": models.app, "title": "Models", "icon": "cpu"},
16
- {"func": demo.app, "title": "Demo", "icon": "cloud-upload"},
17
- ]
18
 
19
- titles = [app["title"] for app in apps]
20
- titles_lower = [title.lower() for title in titles]
21
- icons = [app["icon"] for app in apps]
22
 
23
- #Using "with" notation
24
 
25
- with st.sidebar:
26
- logo = st.image(image)
27
- selected = option_menu(
28
- "Main Menu",
29
- options=titles,
30
- icons=icons,
31
- menu_icon="cast",
32
- )
33
 
34
- for app in apps:
35
- if app["title"] == selected:
36
- app["func"]()
37
- break
 
1
  import streamlit as st
 
2
  from PIL import Image
3
 
 
4
 
5
+ st.set_page_config(layout="wide")
6
  image = Image.open('data/logo.png')
7
  image=image.resize((100,100))
8
+ APP_SUB_TITLE = "by Omdena Milan chapter πŸ‘‡ (https://omdena.com/local-chapters/milan-italy-chapter/)"
9
+ with st.sidebar:
10
+ logo = st.image(image)
11
+ st.caption(APP_SUB_TITLE)
12
 
13
+ import streamlit as st
 
 
 
 
 
14
 
 
 
 
15
 
16
+ st.title("AI for sustainable agriculture and foood systems:Use of Satellite Imagery")
17
 
18
+ st.markdown('''Over five weeks in October 2022, Omdena-Milan Local Chapter collaborators completed
19
+ a local chapter challenge on applying Artificial Intelligence (AI) and Satellite imagery for
20
+ sustainable agri-food systems.To this end, the Omdena-Milan Local Chapter collaborators explored
21
+ various machine learning (ML) and data science techniques and geographic information systems (GIS)
22
+ methods. The team worked on different tasks which are independent of each other to address the same
23
+ project goal. For demonstration, the team integrated all of them into one dashboard with good usability
24
+ for non-technical decision-makers.
25
+ ''')
26
 
 
 
 
 
apps/__pycache__/demo.cpython-37.pyc DELETED
Binary file (362 Bytes)
 
apps/__pycache__/models.cpython-37.pyc DELETED
Binary file (366 Bytes)
 
apps/demo.py DELETED
@@ -1,6 +0,0 @@
1
- import streamlit as st
2
-
3
-
4
-
5
- def app():
6
- st.title("Demo")
 
 
 
 
 
 
 
apps/home.py DELETED
@@ -1,14 +0,0 @@
1
- import streamlit as st
2
-
3
-
4
- def app():
5
-
6
- st.title("AI for sustainable agriculture and foood systems:Use of Satellite Imagery")
7
- st.markdown('''Over five weeks in October 2022, Omdena-Milan Local Chapter collaborators completed
8
- a local chapter challenge on applying Artificial Intelligence (AI) and Satellite imagery for
9
- sustainable agri-food systems.To this end, the Omdena-Milan Local Chapter collaborators explored
10
- various machine learning (ML) and data science techniques and geographic information systems (GIS)
11
- methods. The team worked on different tasks which are independent of each other to address the same
12
- project goal. For demonstration, the team integrated all of them into one dashboard with good usability
13
- for non-technical decision-makers.
14
- ''')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
apps/models.py DELETED
@@ -1,6 +0,0 @@
1
- import streamlit as st
2
-
3
-
4
-
5
- def app():
6
- st.title("Models")
 
 
 
 
 
 
 
{apps β†’ pages}/__pycache__/dashboard.cpython-37.pyc RENAMED
Binary files a/apps/__pycache__/dashboard.cpython-37.pyc and b/pages/__pycache__/dashboard.cpython-37.pyc differ
 
pages/__pycache__/demo.cpython-37.pyc ADDED
Binary file (1.75 kB). View file
 
{apps β†’ pages}/__pycache__/eda.cpython-37.pyc RENAMED
File without changes
{apps β†’ pages}/__pycache__/home.cpython-37.pyc RENAMED
Binary files a/apps/__pycache__/home.cpython-37.pyc and b/pages/__pycache__/home.cpython-37.pyc differ
 
pages/__pycache__/models.cpython-37.pyc ADDED
Binary file (315 Bytes). View file
 
{apps β†’ pages}/dashboard.py RENAMED
@@ -6,55 +6,13 @@ import folium
6
  from PIL import Image
7
  from streamlit_folium import st_folium
8
 
9
- def app():
10
-
11
-
12
- APP_TITLE = "Italy Agrifoods Data"
13
- image = Image.open('data/logo.png')
14
- image=image.resize((100,100))
15
- st.title(APP_TITLE)
16
- #st.set_page_config(layout="wide")
17
-
18
- st.title(APP_TITLE)
19
-
20
-
21
- image = Image.open('data/logo.png')
22
- image=image.resize((100,100))
23
-
24
-
25
- #load data
26
- df_olives = pd.read_csv("data/Italy_regions_with_code_grapes_olives.csv")
27
- df_cereals = pd.read_csv("data/Italy_regions_with_code_cereals.csv")
28
- df_veg = pd.read_csv("data/Italy_regions_with_code_fresh_veg.csv")
29
- df_fruit = pd.read_csv("data/Italy_regions_with_code_fruit.csv")
30
- df = df_fruit
31
- year = ''
32
- region = "Abruzzo"
33
 
34
 
35
 
36
- #st.write(df.shape)
37
- #st.write(df.head())
38
-
39
-
40
- product = display_product()
41
- col1, col2 = st.columns(2)
42
-
43
- #display map
44
- with col1:
45
- year = display_time_filters(df)
46
-
47
- #st.header('{Header!!!!}')
48
- region = display_map(df, year)
49
-
50
- with col2:
51
- #display metric
52
- region = display_state_filter(df, region)
53
- metric_title = f"{product} Harvested Production in Quintals {region} - Italy: {year}"
54
- display_yield(df, year, region, metric_title)
55
-
56
-
57
-
58
  def display_time_filters(df):
59
  year_list = list(df['TIME'].unique())
60
  year_list.sort()
@@ -108,3 +66,55 @@ def display_map(df, year):
108
  return 'Puglia'
109
  return region_name
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  from PIL import Image
7
  from streamlit_folium import st_folium
8
 
9
+ APP_TITLE = "Italy Agrifoods Data"
10
+ APP_SUB_TITLE = "by Omdena Milan chapter πŸ‘‡ (https://omdena.com/local-chapters/milan-italy-chapter/)"
11
+ image = Image.open('data/logo.png')
12
+ image=image.resize((100,100))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
 
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  def display_time_filters(df):
17
  year_list = list(df['TIME'].unique())
18
  year_list.sort()
 
66
  return 'Puglia'
67
  return region_name
68
 
69
+ def main():
70
+ st.set_page_config(APP_TITLE, layout="wide")
71
+ st.title(APP_TITLE)
72
+
73
+
74
+ image = Image.open('data/logo.png')
75
+ image=image.resize((100,100))
76
+
77
+ with st.sidebar:
78
+ logo = st.image(image)
79
+ st.caption(APP_SUB_TITLE)
80
+
81
+ #load data
82
+ df_olives = pd.read_csv("data/Italy_regions_with_code_grapes_olives.csv")
83
+ df_cereals = pd.read_csv("data/Italy_regions_with_code_cereals.csv")
84
+ df_veg = pd.read_csv("data/Italy_regions_with_code_fresh_veg.csv")
85
+ df_fruit = pd.read_csv("data/Italy_regions_with_code_fruit.csv")
86
+ df = df_fruit
87
+ year = ''
88
+ region = ""
89
+
90
+
91
+
92
+ #st.write(df.shape)
93
+ #st.write(df.head())
94
+
95
+
96
+ product = display_product()
97
+ col1, col2 = st.columns([2,1])
98
+
99
+ #display map
100
+ with col2:
101
+ #display metric
102
+ year = display_time_filters(df)
103
+ region = display_state_filter(df, region)
104
+ metric_title = f"{product} Harvested Production in Quintals {region} - Italy: {year}"
105
+ display_yield(df, year, region, metric_title)
106
+
107
+ with col1:
108
+ region = display_map(df, year)
109
+
110
+
111
+ #st.header('{Header!!!!}')
112
+
113
+
114
+
115
+
116
+ #metric_title = f"Harvested Production in Quintals {region} - Italy: {year}"
117
+
118
+ if __name__ == "__main__":
119
+ main()
120
+
pages/demo.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import geopandas as gpd
4
+ from millify import millify
5
+ import folium
6
+ from PIL import Image
7
+ from streamlit_folium import st_folium
8
+
9
+ APP_TITLE = "Italy Agrifoods Data"
10
+ APP_SUB_TITLE = "by Omdena Milan chapter πŸ‘‡ (https://omdena.com/local-chapters/milan-italy-chapter/)"
11
+ image = Image.open('data/logo.png')
12
+ image=image.resize((100,100))
13
+ #st.set_page_config(layout="wide")
14
+
15
+ st.title(APP_TITLE)