Spaces:
Runtime error
Runtime error
Oğuzcan Turan
commited on
Commit
•
02362a0
1
Parent(s):
d892a34
demo added
Browse files
LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2022 Oğuzcan Turan
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE.
|
README.md
CHANGED
@@ -1,13 +1,11 @@
|
|
1 |
---
|
2 |
-
title: Satellighte
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: streamlit
|
7 |
sdk_version: 1.10.0
|
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: Satellighte Streamlit
|
3 |
+
emoji: 📡
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: purple
|
6 |
sdk: streamlit
|
7 |
sdk_version: 1.10.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
11 |
+
---
|
|
|
|
app.py
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import random
|
2 |
+
from datetime import datetime
|
3 |
+
|
4 |
+
import numpy as np
|
5 |
+
import requests
|
6 |
+
import satellighte as sat
|
7 |
+
import streamlit as st
|
8 |
+
from PIL import Image
|
9 |
+
|
10 |
+
|
11 |
+
def main():
|
12 |
+
# pylint: disable=no-member
|
13 |
+
|
14 |
+
st.set_page_config(
|
15 |
+
page_title="Satellighte Demo Page",
|
16 |
+
page_icon="📡",
|
17 |
+
layout="centered",
|
18 |
+
initial_sidebar_state="expanded",
|
19 |
+
menu_items={
|
20 |
+
"Get Help": "https://canturan10.github.io/satellighte/",
|
21 |
+
"About": "Satellite Image Classification",
|
22 |
+
},
|
23 |
+
)
|
24 |
+
|
25 |
+
st.title("Satellighte Demo Page")
|
26 |
+
|
27 |
+
url = "https://raw.githubusercontent.com/canturan10/satellighte/master/src/satellighte.png?raw=true"
|
28 |
+
satellighte = Image.open(requests.get(url, stream=True).raw)
|
29 |
+
|
30 |
+
st.sidebar.image(satellighte, width=100)
|
31 |
+
st.sidebar.title("Satellighte")
|
32 |
+
st.sidebar.caption(sat.__description__)
|
33 |
+
|
34 |
+
st.write(
|
35 |
+
"**Satellighte** is an image classification library that consist state-of-the-art deep learning methods. It is a combination of the words **'Satellite'** and **'Light'**, and its purpose is to establish a light structure to classify satellite images, but to obtain robust results."
|
36 |
+
)
|
37 |
+
|
38 |
+
st.sidebar.caption(f"Version: `{sat.__version__}`")
|
39 |
+
st.sidebar.caption(f"License: `{sat.__license__}`")
|
40 |
+
st.sidebar.caption(sat.__copyright__)
|
41 |
+
|
42 |
+
selected_model = st.selectbox(
|
43 |
+
"Select model",
|
44 |
+
sat.available_models(),
|
45 |
+
)
|
46 |
+
selected_version = st.selectbox(
|
47 |
+
"Select version",
|
48 |
+
sat.get_model_versions(selected_model),
|
49 |
+
)
|
50 |
+
|
51 |
+
model = sat.Classifier.from_pretrained(selected_model, selected_version)
|
52 |
+
model.eval()
|
53 |
+
|
54 |
+
uploaded_file = st.file_uploader(
|
55 |
+
"", type=["png", "jpg", "jpeg"], accept_multiple_files=False
|
56 |
+
)
|
57 |
+
|
58 |
+
if uploaded_file is None:
|
59 |
+
st.write("Sample Image")
|
60 |
+
# Sample image.
|
61 |
+
url = f"https://raw.githubusercontent.com/canturan10/satellighte/master/src/eurosat_samples/{random_sample}?raw=true"
|
62 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
63 |
+
|
64 |
+
else:
|
65 |
+
# User-selected image.
|
66 |
+
image = Image.open(uploaded_file)
|
67 |
+
|
68 |
+
image = np.array(image.convert("RGB"))
|
69 |
+
FRAME_WINDOW = st.image([], use_column_width=True)
|
70 |
+
|
71 |
+
model = sat.Classifier.from_pretrained(selected_model, selected_version)
|
72 |
+
model.eval()
|
73 |
+
|
74 |
+
results = model.predict(image)
|
75 |
+
pil_img = sat.utils.visualize(image, results)
|
76 |
+
|
77 |
+
st.write("Results:", results)
|
78 |
+
FRAME_WINDOW.image(pil_img)
|
79 |
+
|
80 |
+
|
81 |
+
if __name__ == "__main__":
|
82 |
+
samples = [
|
83 |
+
"AnnualCrop.jpg",
|
84 |
+
"Forest.jpg",
|
85 |
+
"HerbaceousVegetation.jpg",
|
86 |
+
"PermanentCrop.jpg",
|
87 |
+
"River.jpg",
|
88 |
+
]
|
89 |
+
random.seed(datetime.now())
|
90 |
+
random_sample = samples[random.randint(0, len(samples) - 1)]
|
91 |
+
|
92 |
+
main()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
satellighte
|
2 |
+
streamlit~=1.11.1
|