Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import numpy as np | |
| import pandas as pd | |
| import tensorflow as tf | |
| from tensorflow import keras | |
| from tensorflow.keras.preprocessing.text import Tokenizer | |
| from tensorflow.keras.preprocessing.sequence import pad_sequences | |
| #loading the saved model | |
| from keras.models import load_model | |
| model = load_model('Model.h5') | |
| def page(word): | |
| num_words=3000 | |
| tokenizer=Tokenizer(num_words=num_words,oov_token='oov') | |
| tokenizer.fit_on_texts(word) | |
| word_tk= tokenizer.texts_to_sequences([word]) | |
| word_pad= pad_sequences(word_tk, maxlen=10) | |
| prediction = model.predict(word_pad) | |
| f_prediction= np.argmax(prediction) | |
| if f_prediction == 1: | |
| return "Seller is authentic, page recommended" | |
| elif f_prediction ==2: | |
| return "Seller is not authentic, page not recommended" | |
| elif f_prediction ==3: | |
| return "Seller is not authentic, page not recommended" | |
| else: | |
| return "Error" | |
| demo=gr.Interface(fn=page, | |
| inputs=gr.Textbox(placeholder="Enter your review and the rating to check the authenticity of any product or page"), | |
| outputs="text") | |
| demo.launch(debug=True) |