Commit
·
ea326f6
1
Parent(s):
d791520
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pickle
|
2 |
+
import cv2
|
3 |
+
from fastai.vision.all import *
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
im_size = (1152, 768)
|
7 |
+
with open("learn.pkl", 'rb') as f:
|
8 |
+
model = pickle.load(f)
|
9 |
+
|
10 |
+
def predict_mask(file):
|
11 |
+
img = cv2.imdecode(np.frombuffer(file.read(), np.uint8), cv2.IMREAD_GRAYSCALE)
|
12 |
+
img = cv2.resize(img, im_size)
|
13 |
+
pred = model.predict(img)
|
14 |
+
return pred[0]
|
15 |
+
|
16 |
+
iface = gr.Interface(fn=predict_mask,
|
17 |
+
inputs=gr.inputs.Image(label="Upload Image"),
|
18 |
+
outputs="image",
|
19 |
+
capture_session=True,
|
20 |
+
interpretation="default")
|
21 |
+
|
22 |
+
if __name__ == "__main__":
|
23 |
+
iface.launch()
|