Spaces:
Sleeping
Sleeping
File size: 814 Bytes
b56c828 b1dc1be b56c828 b1dc1be b56c828 b1dc1be b56c828 09a7974 |
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 |
import torch
import streamlit as st
from model import init_model, predict
from data import Tokenizer, load_config
MODEL_PATH = 'tj-fa.pt'
config = load_config(MODEL_PATH)
print('Config:', config)
tokenizer = Tokenizer(config)
# Load the model
model = init_model(MODEL_PATH)
# Create a text area box where the user can enter their text
user_input = st.text_area("Enter some text here", value="Он ҷо, ки висоли дӯстон аст,\nВ-оллоҳ, ки миёни хона саҳрост.")
device = "cuda" if torch.cuda.is_available() else "cpu"
# Run the model on the user's text and store the output
model_output = predict(model, tokenizer, user_input, device)
# Display the model's output in a text area box
st.text_area('Transliteration:', value=str(model_output), max_chars=None, key=None)
|