Commit
·
3d8c338
1
Parent(s):
04a8088
first working space
Browse files- .gitattributes +1 -0
- .gitignore +64 -0
- README.md +3 -2
- app.py +53 -0
- data/GM18.mat +3 -0
- data/GM18_pred.png +0 -0
- requirements.txt +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
*.mat filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# Distribution / packaging
|
7 |
+
.Python
|
8 |
+
build/
|
9 |
+
develop-eggs/
|
10 |
+
dist/
|
11 |
+
downloads/
|
12 |
+
eggs/
|
13 |
+
.eggs/
|
14 |
+
lib/
|
15 |
+
lib64/
|
16 |
+
parts/
|
17 |
+
sdist/
|
18 |
+
var/
|
19 |
+
wheels/
|
20 |
+
share/python-wheels/
|
21 |
+
*.egg-info/
|
22 |
+
.installed.cfg
|
23 |
+
*.egg
|
24 |
+
MANIFEST
|
25 |
+
|
26 |
+
# PyInstaller
|
27 |
+
# Usually these files are written by a python script from a template
|
28 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
29 |
+
*.manifest
|
30 |
+
*.spec
|
31 |
+
|
32 |
+
# Installer logs
|
33 |
+
pip-log.txt
|
34 |
+
pip-delete-this-directory.txt
|
35 |
+
|
36 |
+
# Unit test / coverage reports
|
37 |
+
htmlcov/
|
38 |
+
.tox/
|
39 |
+
.nox/
|
40 |
+
.coverage
|
41 |
+
.coverage.*
|
42 |
+
.cache
|
43 |
+
nosetests.xml
|
44 |
+
coverage.xml
|
45 |
+
*.cover
|
46 |
+
*.py,cover
|
47 |
+
.hypothesis/
|
48 |
+
.pytest_cache/
|
49 |
+
cover/
|
50 |
+
|
51 |
+
# pyenv
|
52 |
+
.python-version
|
53 |
+
|
54 |
+
# Environments
|
55 |
+
.env
|
56 |
+
.venv
|
57 |
+
env/
|
58 |
+
venv/
|
59 |
+
ENV/
|
60 |
+
env.bak/
|
61 |
+
venv.bak/
|
62 |
+
|
63 |
+
# vscode
|
64 |
+
.vscode/
|
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
-
title: Hyperspectral
|
3 |
-
emoji:
|
4 |
colorFrom: purple
|
5 |
colorTo: blue
|
6 |
sdk: streamlit
|
@@ -8,6 +8,7 @@ sdk_version: 1.43.2
|
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
|
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: Hyperspectral Oil Spill Detection
|
3 |
+
emoji: 🛢️
|
4 |
colorFrom: purple
|
5 |
colorTo: blue
|
6 |
sdk: streamlit
|
|
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
11 |
+
description: Model for Detecting Oil Spills Using Hyperspectral Images
|
12 |
---
|
13 |
|
14 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from scipy.io import loadmat
|
3 |
+
import imageio.v2 as imageio
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
MAT_FILE = "data/GM18.mat"
|
7 |
+
PRED_FILE = "data/GM18_pred.png"
|
8 |
+
|
9 |
+
@st.cache_data
|
10 |
+
def load_data():
|
11 |
+
input_data = loadmat(MAT_FILE)
|
12 |
+
input_image = input_data["img"]
|
13 |
+
gt_image = input_data["map"]
|
14 |
+
pred_image = imageio.imread(PRED_FILE)
|
15 |
+
# normalize the images between max and min
|
16 |
+
gt_image = (gt_image - gt_image.min()) / (gt_image.max() - gt_image.min())
|
17 |
+
pred_image = (pred_image - pred_image.min()) / \
|
18 |
+
(pred_image.max() - pred_image.min())
|
19 |
+
# normalize between 5 and 95 percentile
|
20 |
+
input_image = (input_image - np.percentile(input_image, 5, axis=(0, 1))) / \
|
21 |
+
(np.percentile(input_image, 95, axis=(0, 1)) -
|
22 |
+
np.percentile(input_image, 5, axis=(0, 1)))
|
23 |
+
input_image = np.clip(input_image, 0, 1)
|
24 |
+
return input_image, gt_image, pred_image
|
25 |
+
|
26 |
+
def main():
|
27 |
+
# add a title
|
28 |
+
st.title("Hyperspectral Sea Oil Spill Detection")
|
29 |
+
# add description
|
30 |
+
st.write("This app displays an example of hyperspectral image of a sea oil spill, ground truth, and predicted image.")
|
31 |
+
input_image, gt_image, pred_image = load_data()
|
32 |
+
# Add a slider to select the channel
|
33 |
+
channel = st.slider("Hypersepctral images have a large number of channels, select a channel to display:", min_value=1, max_value=224, value=1)
|
34 |
+
# Create columns
|
35 |
+
col1, col2, col3 = st.columns(3)
|
36 |
+
# Display the images in columns
|
37 |
+
with col1:
|
38 |
+
st.image(input_image[:, :, channel-1], caption=f"Channel {channel}", use_container_width=True)
|
39 |
+
with col2:
|
40 |
+
st.image(gt_image, caption="Ground Truth", use_container_width=True)
|
41 |
+
with col3:
|
42 |
+
st.image(pred_image, caption="Predicted", use_container_width=True)
|
43 |
+
# print a table with the metrics
|
44 |
+
st.write("## Results")
|
45 |
+
st.write("The following table shows the metrics of the predicted image compared to the ground truth. The metrics are accuracy and intersection over union. The values are between 0 and 1, where 1 is the best value.")
|
46 |
+
# add a table with the results
|
47 |
+
st.table({
|
48 |
+
"Metric": ["Accuracy, sea", "Accuracy, oil", "Accuracy, average", "IOU, sea", "IOU, oil", "IOU, average"],
|
49 |
+
"Result": [0.962, 0.934, 0.948, 0.954, 0.719, 0.837]
|
50 |
+
})
|
51 |
+
|
52 |
+
if __name__ == "__main__":
|
53 |
+
main()
|
data/GM18.mat
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cc2d55311834acf32912969cfb9ae8bfce37be06e402d04bb3183f4afe4f1e7a
|
3 |
+
size 100464295
|
data/GM18_pred.png
ADDED
![]() |
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
scipy==1.15.2
|
2 |
+
imageio==2.37.0
|
3 |
+
numpy==2.2.4
|