saritha5 commited on
Commit
3f605a0
·
1 Parent(s): 1d1f5b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -1
app.py CHANGED
@@ -80,4 +80,47 @@ else:
80
  #st.header(predicted_label)
81
  #st.header(str(round(variance_score,2)))
82
  string = "The image is," + str(predicted_label) + " with the score value of " + str(round(variance_score,2))
83
- st.header(string)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  #st.header(predicted_label)
81
  #st.header(str(round(variance_score,2)))
82
  string = "The image is," + str(predicted_label) + " with the score value of " + str(round(variance_score,2))
83
+ st.subheader(string)
84
+
85
+ st.header("Prediction of Occluded or not Occluded ")
86
+ plt. figure(figsize=(10,9))
87
+ def occ_predict(img_content):
88
+ im = []
89
+ image=cv2.imread(img_content)
90
+ imgplot = plt.imshow(image)
91
+ plt.show()
92
+ img = Image.fromarray(image, 'RGB')
93
+ resize_image = img.resize((50, 50))
94
+ im.append(np.array(resize_image))
95
+ fv = np.array(im)
96
+ np_array_img = fv.astype('float32') / 255
97
+ model_gcs = h5py.File(model_file_path, 'r')
98
+ myModel = load_model(model_gcs)
99
+ prediction = myModel.predict(np_array_img)
100
+ score = prediction[0][0].item()
101
+ thresh = 0.5
102
+ if score > thresh:
103
+ return "Not Occluded",score
104
+ else:
105
+ return "Occluded",score
106
+
107
+ f = st.file_uploader('Upload an Image',type=(["jpeg","jpg","png"]))
108
+ st.subheader("Prediction of Blur or NotBlur Image")
109
+ images1 = ["blur1.png","blurimg2.png","blurimg3.png","images_11.jpeg"]
110
+ with st.sidebar:
111
+ st.write("choose an image")
112
+ st.image(images)
113
+
114
+ if f is None:
115
+ st.write("Please upload an image file")
116
+ else:
117
+ image1= Image.open(f)
118
+ st.image(image1,use_column_width = True)
119
+ predicted_label1,variance_score1 = occ_predict(f)
120
+ #st.header(predicted_label)
121
+ #st.header(str(round(variance_score,2)))
122
+ string1 = "The image is," + str(predicted_label1) + " with the score value of " + str(round(variance_score1,2))
123
+ st.subheader(string1)
124
+
125
+ #predicted_label, score = occ_predict("/content/drive/MyDrive/Occulded.jpg")
126
+ #print("The image is", '\033[1m' + predicted_label1 + '\033[0m', "with the score value of" ,round(score,2))