Views
No views yet
1import torch
2from huggingface_hub import hf_hub_download
3from model import EncoderRNN, DecoderRNN, tensorFromSentence
4
5# Download trained models
6encoder_path = hf_hub_download("Mikile/Bertha-translation", "encoder.pth")
7decoder_path = hf_hub_download("Mikile/Bertha-translation", "decoder.pth")
8
9# Load your encoder and decoder
10encoder = EncoderRNN(input_size, hidden_size)
11decoder = DecoderRNN(hidden_size, output_size)
12encoder.load_state_dict(torch.load(encoder_path))
13decoder.load_state_dict(torch.load(decoder_path))
14
15# Translate a sentence
16sentence = "hello my friend"
17input_tensor = tensorFromSentence(input_lang, sentence)
18encoder_outputs, encoder_hidden = encoder(input_tensor)
19decoder_outputs, _, _ = decoder(encoder_outputs, encoder_hidden)
20
21
22@misc{bertha_translation,
23 author = {Mikiyas Zenebe},
24 title = {Bertha ↔ English Translation Model},
25 year = {2025},
26 howpublished = {Hugging Face Model Hub},
27 url = {https://huggingface.co/Mikile/Bertha-translation}
28}