willco-afk
commited on
Commit
·
7c69e90
1
Parent(s):
05a2759
Add Gradio interface
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from tensorflow.keras.models import load_model
|
| 3 |
+
import json
|
| 4 |
+
|
| 5 |
+
# Load model and tokenizer
|
| 6 |
+
model = load_model('my_model.h5')
|
| 7 |
+
|
| 8 |
+
with open('tokenizer.json', 'r') as f:
|
| 9 |
+
tokenizer = json.load(f)
|
| 10 |
+
|
| 11 |
+
# Define prediction function
|
| 12 |
+
def predict(text):
|
| 13 |
+
# Implement your tokenization and model prediction logic here
|
| 14 |
+
# Example:
|
| 15 |
+
tokens = tokenizer.texts_to_sequences([text])
|
| 16 |
+
prediction = model.predict(tokens)
|
| 17 |
+
return prediction
|
| 18 |
+
|
| 19 |
+
# Set up Gradio interface
|
| 20 |
+
iface = gr.Interface(fn=predict, inputs="text", outputs="text")
|
| 21 |
+
|
| 22 |
+
# Launch the interface
|
| 23 |
+
iface.launch()
|