import gradio as gr # Matplotlib import matplotlib.pyplot as plt # Tensorflow import tensorflow as tf # Numpy and Pandas import numpy as np import pandas as pd # Ohter import import sys from numpy import zeros,array StandardInstanceSize=50 import json model = tf.keras.models.load_model('model.h5') # Opening JSON file with open('model_vocab_to_int') as json_file: vocab_to_int = json.load(json_file) def greet(Word_pair): #item=w1+" "+w2 item=Word_pair item=item.ljust(StandardInstanceSize) instances = zeros((1, StandardInstanceSize), float) instances[0]=([vocab_to_int[l] for l in item]) instances=instances.astype(float) return model.predict(instances)[0] iface = gr.Interface(fn=greet, inputs="text", outputs="text") iface.launch()