Update app.py
Browse files
app.py
CHANGED
@@ -5,15 +5,21 @@ import requests
|
|
5 |
from io import BytesIO
|
6 |
|
7 |
# This is a placeholder for your image classification function
|
8 |
-
def
|
9 |
-
|
10 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# Title
|
13 |
st.title("Image Classification Web App")
|
14 |
|
15 |
# Intro
|
16 |
-
st.write("Please provide a Satellite image for classification
|
17 |
|
18 |
# Image input via URL
|
19 |
url = st.text_input("Image URL")
|
@@ -31,16 +37,45 @@ if uploaded_file is not None:
|
|
31 |
image = Image.open(uploaded_file)
|
32 |
st.image(image, caption='Uploaded Image', use_column_width=True)
|
33 |
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
36 |
if url or uploaded_file:
|
37 |
-
results =
|
38 |
if results:
|
39 |
# Use markdown to present the results
|
40 |
for result in results:
|
41 |
-
|
42 |
else:
|
43 |
-
|
44 |
else:
|
45 |
-
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
from io import BytesIO
|
6 |
|
7 |
# This is a placeholder for your image classification function
|
8 |
+
def classify_image1(image):
|
9 |
+
pipe1 = pipeline("image-classification", "SolubleFish/swin_transformer-finetuned-eurosat")
|
10 |
+
return pipe1(image)
|
11 |
+
def classify_image2(image):
|
12 |
+
pipe2 = pipeline("image-classification", "SolubleFish/image_classification_convnext")
|
13 |
+
return pipe2(image)
|
14 |
+
def classify_image3(image):
|
15 |
+
pipe3 = pipeline("image-classification", "SolubleFish/image_classification_vit")
|
16 |
+
return pipe3(image)
|
17 |
|
18 |
# Title
|
19 |
st.title("Image Classification Web App")
|
20 |
|
21 |
# Intro
|
22 |
+
st.write("Please provide a Satellite image for classification")
|
23 |
|
24 |
# Image input via URL
|
25 |
url = st.text_input("Image URL")
|
|
|
37 |
image = Image.open(uploaded_file)
|
38 |
st.image(image, caption='Uploaded Image', use_column_width=True)
|
39 |
|
40 |
+
|
41 |
+
# Create three columns
|
42 |
+
col1, col2, col3 = st.columns(3)
|
43 |
+
|
44 |
+
# Classification button for classify_image1
|
45 |
+
if col1.button("Classify Image by swin"):
|
46 |
if url or uploaded_file:
|
47 |
+
results = classify_image1(image)
|
48 |
if results:
|
49 |
# Use markdown to present the results
|
50 |
for result in results:
|
51 |
+
col1.markdown(f"**Class name:** {result['label']} \n\n **Confidence:** {str(format(result['score']*100, '.2f'))}"+"%")
|
52 |
else:
|
53 |
+
col1.write("No results found.")
|
54 |
else:
|
55 |
+
col1.write("Please provide an image for classification.")
|
56 |
|
57 |
+
# Classification button for classify_image2
|
58 |
+
if col2.button("Classify Image by convnext"):
|
59 |
+
if url or uploaded_file:
|
60 |
+
results = classify_image2(image)
|
61 |
+
if results:
|
62 |
+
# Use markdown to present the results
|
63 |
+
for result in results:
|
64 |
+
col2.markdown(f"**Class name:** {result['label']} \n\n **Confidence:** {str(format(result['score']*100, '.2f'))}"+"%")
|
65 |
+
else:
|
66 |
+
col2.write("No results found.")
|
67 |
+
else:
|
68 |
+
col2.write("Please provide an image for classification.")
|
69 |
+
|
70 |
+
# Classification button for classify_image3
|
71 |
+
if col3.button("Classify Image by vit"):
|
72 |
+
if url or uploaded_file:
|
73 |
+
results = classify_image3(image)
|
74 |
+
if results:
|
75 |
+
# Use markdown to present the results
|
76 |
+
for result in results:
|
77 |
+
col3.markdown(f"**Class name:** {result['label']} \n\n **Confidence:** {str(format(result['score']*100, '.2f'))}"+"%")
|
78 |
+
else:
|
79 |
+
col3.write("No results found.")
|
80 |
+
else:
|
81 |
+
col3.write("Please provide an image for classification.")
|