ddovidovich
commited on
Commit
·
7be5e7c
1
Parent(s):
6e96c04
Update app.py
Browse files
app.py
CHANGED
|
@@ -97,4 +97,32 @@ if image_file is not None:
|
|
| 97 |
st.write(output.shape)
|
| 98 |
st.image(output,width=850)
|
| 99 |
|
| 100 |
-
st.text("DONE ! ....")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
st.write(output.shape)
|
| 98 |
st.image(output,width=850)
|
| 99 |
|
| 100 |
+
st.text("DONE ! ....")
|
| 101 |
+
|
| 102 |
+
if image_file is not None:
|
| 103 |
+
img=load_image(image_file)
|
| 104 |
+
|
| 105 |
+
st.text("Making A Prediction ....")
|
| 106 |
+
st.image(img,width=850)
|
| 107 |
+
|
| 108 |
+
img=np.asarray(img)
|
| 109 |
+
|
| 110 |
+
img_cv=convert_one_channel(img)
|
| 111 |
+
img_cv=cv2.resize(img_cv,(512,512), interpolation=cv2.INTER_LANCZOS4)
|
| 112 |
+
img_cv=np.float32(img_cv/255)
|
| 113 |
+
|
| 114 |
+
img_cv=np.reshape(img_cv,(1,512,512,1))
|
| 115 |
+
predict_img=model.predict(img_cv)
|
| 116 |
+
predict=predict_img[1,:,:,0]
|
| 117 |
+
plt.imsave("/content/predict.png",predict)
|
| 118 |
+
|
| 119 |
+
## Plotting - Пример результата
|
| 120 |
+
img = cv2.imread("/content/Data/Images/107.png") # оригинальное изображение 107.png
|
| 121 |
+
|
| 122 |
+
predict1 = cv2.resize(predict, (img.shape[1], img.shape[0]), interpolation=cv2.INTER_LANCZOS4)
|
| 123 |
+
|
| 124 |
+
mask = np.uint8(predict1 * 255)
|
| 125 |
+
_, mask = cv2.threshold(mask, thresh=255/2, maxval=255, type=cv2.THRESH_BINARY)
|
| 126 |
+
cnts, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
| 127 |
+
img = cv2.drawContours(img, cnts, -1, (255, 0, 0), 2)
|
| 128 |
+
cv2_imshow(img)
|