Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -30,4 +30,37 @@ import h5py
|
|
30 |
|
31 |
st.title('Image Bluriness Occulded')
|
32 |
|
33 |
-
model_file_path = "mobile_net_occ.h5"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
st.title('Image Bluriness Occulded')
|
32 |
|
33 |
+
model_file_path = "mobile_net_occ.h5"
|
34 |
+
|
35 |
+
##Blurriness Features
|
36 |
+
|
37 |
+
plt. figure(figsize=(10,9))
|
38 |
+
def variance_of_laplacian(image):
|
39 |
+
return cv2.Laplacian(image, cv2.CV_64F).var()
|
40 |
+
|
41 |
+
def threshold(value, thresh):
|
42 |
+
if value > thresh:
|
43 |
+
return "Not Blur"
|
44 |
+
else:
|
45 |
+
return "Blur"
|
46 |
+
def blurr_predict(img_iter):
|
47 |
+
|
48 |
+
def make_prediction(img_content):
|
49 |
+
pil_image = Image.open(img_content)
|
50 |
+
imgplot = plt.imshow(pil_image)
|
51 |
+
plt.show()
|
52 |
+
gray_cvimage = cv2.cvtColor(np.array(pil_image), cv2.COLOR_RGB2GRAY)
|
53 |
+
#print(gray_cvimage)
|
54 |
+
variance_laplacian = variance_of_laplacian(gray_cvimage)
|
55 |
+
#print(variance_laplacian)
|
56 |
+
return variance_laplacian
|
57 |
+
|
58 |
+
variance_score = make_prediction(img_iter)
|
59 |
+
thresh = 2000
|
60 |
+
variance_score = variance_score/thresh
|
61 |
+
predicted_label = threshold(variance_score, 1)
|
62 |
+
return predicted_label,variance_score
|
63 |
+
|
64 |
+
image_path = "images_11.jpeg"
|
65 |
+
predicted_label,variance_score = blurr_predict(image_path)
|
66 |
+
print("The image is", '\033[1m' + predicted_label + '\033[0m', "with the score value of" ,round(variance_score,2))
|