Spaces:
Sleeping
Sleeping
| 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(Word1, Word2): | |
| item=Word1+" "+Word2 | |
| #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) | |
| val=model.predict(instances)[0] | |
| percentage = "{:.0%}".format(val[1]) | |
| return percentage | |
| iface = gr.Interface(fn=greet, inputs=["text", "text"], outputs="text") | |
| iface.launch() |