Spaces:
Build error
Build error
Commit
•
7e11116
1
Parent(s):
c99b419
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import keras
|
3 |
+
from keras.models import load_model
|
4 |
+
from tensorflow_addons.layers import InstanceNormalization
|
5 |
+
import matplotlib.pyplot as plt
|
6 |
+
import numpy as np
|
7 |
+
|
8 |
+
model=load_model('g_model_AtoB_002160.h5')
|
9 |
+
|
10 |
+
def show_preds_image(image_path):
|
11 |
+
image = plt.imread(image_path)
|
12 |
+
image=np.expand_dims(image,axis=0)
|
13 |
+
outputs = model.predict(image)
|
14 |
+
image=np.squeeze(outputs,axis=0)
|
15 |
+
return image
|
16 |
+
|
17 |
+
inputs_image = [
|
18 |
+
gr.components.Image(type="filepath", label="Input Image"),
|
19 |
+
]
|
20 |
+
outputs_image = [
|
21 |
+
gr.components.Image(type="numpy", label="Output Image"),
|
22 |
+
]
|
23 |
+
interface_image = gr.Interface(
|
24 |
+
fn=show_preds_image,
|
25 |
+
inputs=inputs_image,
|
26 |
+
outputs=outputs_image,
|
27 |
+
title="Pothole detector",
|
28 |
+
examples=path,
|
29 |
+
cache_examples=False,
|
30 |
+
)
|
31 |
+
|
32 |
+
gr.TabbedInterface(
|
33 |
+
[interface_image],
|
34 |
+
tab_names=['Image inference']
|
35 |
+
).queue().launch()
|
36 |
+
|