Priyanka-Kumavat-At-TE
commited on
Commit
•
ad52348
1
Parent(s):
4feb29a
Update app.py
Browse files
app.py
CHANGED
@@ -13,14 +13,24 @@ import cv2
|
|
13 |
import numpy as np
|
14 |
from sklearn.ensemble import RandomForestClassifier
|
15 |
|
16 |
-
st.title("Image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
# Load the saved random forest classifier model
|
19 |
with open('image_blur_model.pkl', 'rb') as f:
|
20 |
clf = pickle.load(f)
|
21 |
|
22 |
# For sample images as a sidebar
|
23 |
-
images = ["test2.jpg","test1.jpg","
|
|
|
24 |
with st.sidebar:
|
25 |
st.write("Choose an image")
|
26 |
st.image(images)
|
@@ -39,15 +49,15 @@ def predict_bluriness(image):
|
|
39 |
return prediction, vol
|
40 |
|
41 |
|
42 |
-
#
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
|
52 |
# File uploader
|
53 |
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
|
|
|
13 |
import numpy as np
|
14 |
from sklearn.ensemble import RandomForestClassifier
|
15 |
|
16 |
+
st.title("Image Blur Prediction System")
|
17 |
+
|
18 |
+
st.write("""Image Bluriness Prediction Model allows users to analyze the bluriness of images.
|
19 |
+
It utilizes a pre-trained random forest classifier model to predict whether an image is blurry or not.
|
20 |
+
The application provides two options for image selection:
|
21 |
+
users can either upload their own image or choose from a set of sample images.
|
22 |
+
Once an image is selected, the application calculates the Variance of Laplacian (VoL) score,
|
23 |
+
a metric used to measure image bluriness. The classifier model then predicts whether the image is blurry or not based
|
24 |
+
on the VoL score. The prediction result and the VoL score are displayed to the user.
|
25 |
+
The application also includes a sidebar that showcases sample images for quick testing.""")
|
26 |
|
27 |
# Load the saved random forest classifier model
|
28 |
with open('image_blur_model.pkl', 'rb') as f:
|
29 |
clf = pickle.load(f)
|
30 |
|
31 |
# For sample images as a sidebar
|
32 |
+
images = ["test2.jpg","test1.jpg","test4.jpg","test5.jpg","test6.jpg","download1.jpg","download2.jpg","sample1.jpg",
|
33 |
+
"download3.jpg","download4.jpg","download.png","img1.jpg","img17.jpg"]
|
34 |
with st.sidebar:
|
35 |
st.write("Choose an image")
|
36 |
st.image(images)
|
|
|
49 |
return prediction, vol
|
50 |
|
51 |
|
52 |
+
# CSS code for changing color of the button
|
53 |
+
st.markdown("""
|
54 |
+
<style>
|
55 |
+
.stButton button {
|
56 |
+
background-color: #668f45;
|
57 |
+
color: white;
|
58 |
+
}
|
59 |
+
</style>
|
60 |
+
""", unsafe_allow_html=True)
|
61 |
|
62 |
# File uploader
|
63 |
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
|