mikonvergence commited on
Commit
90b25f5
β€’
1 Parent(s): 527bb0b

Upload 4 files

Browse files
Files changed (4) hide show
  1. Dockerfile +22 -0
  2. README.md +4 -4
  3. app.py +86 -0
  4. requirements.txt +13 -0
Dockerfile ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11
2
+
3
+ # Set up a new user named "user" with user ID 1000 for permission
4
+ RUN useradd -m -u 1000 user
5
+ # Switch to the "user" user
6
+ USER user
7
+ # Set home to the user's home directory
8
+ ENV HOME=/home/user \
9
+ PATH=/home/user/.local/bin:$PATH
10
+
11
+ # Upgreade pip
12
+ RUN pip install --no-cache-dir --upgrade pip
13
+
14
+ COPY --chown=user requirements.txt .
15
+
16
+ # Install requirements
17
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
18
+
19
+ COPY --chown=user *.py *.css /
20
+ COPY --chown=user helpers/* /helpers/
21
+
22
+ ENTRYPOINT ["solara", "run", "app.py", "--host=0.0.0.0", "--port", "7860", "--production"]
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
- title: MajorTOM Core Viewer
3
- emoji: 🐠
4
- colorFrom: yellow
5
- colorTo: purple
6
  sdk: docker
7
  pinned: false
8
  ---
 
1
  ---
2
+ title: Major TOM Viewer Solara
3
+ emoji: 🌍
4
+ colorFrom: indigo
5
+ colorTo: blue
6
  sdk: docker
7
  pinned: false
8
  ---
app.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ import os
3
+ import leafmap
4
+ from helpers.grid import *
5
+ from helpers.functional import *
6
+ from leafmap.toolbar import change_basemap
7
+ from IPython.display import display
8
+ import ipywidgets
9
+ import solara
10
+
11
+ instructions_top = '''
12
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6304c06eeb6d777a838eab63/A07zVbed5h19KJSV9u4NI.png)
13
+ # Dataset Viewer
14
+
15
+ This app provides a way of exploring samples present in the MajorTOM-Core dataset.
16
+ It contains nearly every piece of Earth capture by ESA Sentinel-2 satellite.
17
+
18
+ ### Instructions
19
+ To find a sample, navigate on the map to a place of interest. Click `Find Sample` to find a dataset sample that contains the central pixel of your current view.
20
+ '''
21
+
22
+ instructions_bottom = '''
23
+ <details><summary><strong>🏝 Couldn't find a sample? See this figure of global coverage:</strong></summary>
24
+ <img src='https://cdn-uploads.huggingface.co/production/uploads/6304c06eeb6d777a838eab63/2KTarfsM0a1dNYEbXriUH.png' />
25
+ </details>
26
+ '''
27
+
28
+ image_data = solara.reactive(Image.new('RGB',(1068,1068)))
29
+ center = solara.reactive((20, 0))
30
+ zoom= solara.reactive(4)
31
+ s2_level = solara.reactive('L2A')
32
+
33
+ @solara.component
34
+ def Page():
35
+ with solara.Column():
36
+
37
+ with solara.Card(margin=10):
38
+ solara.Markdown(instructions_top)
39
+ solara.Button(label="Website",
40
+ icon_name="mdi-map-legend",
41
+ attributes={"href": 'https://www.huggingface.co/Major-TOM', "target": "_blank"},
42
+ text=True,
43
+ outlined=True)
44
+
45
+ solara.Button(label="arXiv Paper",
46
+ icon_name="mdi-script-text",
47
+ attributes={"href": 'https://www.arxiv.org/abs/2402.12095', "target": "_blank"},
48
+ text=True,
49
+ outlined=True)
50
+ solara.Markdown(instructions_bottom)
51
+
52
+ def update_image():
53
+ ret = map_to_image(m, return_centre=True, l2a=(s2_level.value=='L2A'))
54
+ if ret is not None:
55
+ image_data.value, center.value = ret
56
+ zoom.value=12
57
+ else:
58
+ image_data.value = Image.new('RGB',(1068,1068))
59
+ center.value = (20,0)
60
+ zoom.value = 4
61
+
62
+ def update_level(level):
63
+ s2_level.value = level
64
+ update_image()
65
+
66
+ with solara.Card(margin=10):
67
+ with solara.ColumnsResponsive(default=12, small=12, medium=6, large=6, xlarge=6):
68
+ with solara.Column(align='center'):
69
+ solara.Select(label="Processing Level", value=s2_level, values=['L2A','L1C'], on_value=update_level)
70
+ m = leafmap.Map(
71
+ #height=500px,
72
+ width='50em',
73
+ layout=ipywidgets.Layout(flex='1 1 auto', width='500px', height='500px', max_width='90rem'),
74
+ zoom=zoom.value,
75
+ center=center.value,
76
+ draw_control=False,
77
+ measure_control=False,
78
+ fullscreen_control=False,
79
+ toolbar_control=False,
80
+ attribution_control=True,
81
+ )
82
+ display(m)
83
+ button = solara.Button("Find Sample", on_click=update_image, height='80px')
84
+ with solara.Column(align='center'):
85
+ output = solara.Image(image_data.value)
86
+
requirements.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ leafmap
2
+ mapwidget
3
+ solara
4
+ geopandas
5
+ fsspec
6
+ pyarrow
7
+ shapely
8
+ pandas
9
+ numpy
10
+ tqdm
11
+ requests
12
+ aiohttp
13
+ pydantic<2.0