File size: 1,088 Bytes
683300a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
764c7a4
683300a
 
 
 
764c7a4
683300a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import gradio as gr
import keras
from keras.models import load_model
# from keras_contrib.layers.normalization.instancenormalization import InstanceNormalization
from tensorflow_addons.layers import InstanceNormalization
import matplotlib.pyplot as plt
import numpy as np

cust = {'InstanceNormalization': InstanceNormalization}
model=load_model('g_model_AtoB_002160.h5',cust)
path  = [['ex1.jpg'], ['ex2.jpg']]

def show_preds_image(image_path):
    A = plt.imread(image_path)
    A = (A - 127.5) / 127.5
    A = np.expand_dims(A,axis=0)
    B = model.predict(A)
    B = np.squeeze(B,axis=0)
    B = (B + 1) / 2.0
    return B
 
inputs_image = [
    gr.components.Image(shape=(256,256),type="filepath", label="Input Image"),
]
outputs_image = [
    gr.components.Image(type="numpy", label="Output Image"),
]
interface_image = gr.Interface(
    fn=show_preds_image,
    inputs=inputs_image,
    outputs=outputs_image,
    title="photo2monet",
    examples=path,
    cache_examples=False,
)

gr.TabbedInterface(
    [interface_image],
    tab_names=['Image inference']
).queue().launch()