Update app.py
Browse files
app.py
CHANGED
|
@@ -166,27 +166,27 @@ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
| 166 |
# 🔴 CHANGE THIS: your actual model repo id
|
| 167 |
MODEL_REPO = "harishwar017/transliteration_transformer"
|
| 168 |
|
| 169 |
-
# Download files from HF Hub into the Space’s local cache
|
| 170 |
-
src_json_path = hf_hub_download(repo_id=MODEL_REPO, filename="src_stoi.json")
|
| 171 |
-
tgt_json_path = hf_hub_download(repo_id=MODEL_REPO, filename="tgt_stoi.json")
|
| 172 |
model_path = hf_hub_download(repo_id=MODEL_REPO, filename="best_hindi_roman_transformer.pt")
|
| 173 |
|
| 174 |
-
# Load vocabularies
|
| 175 |
-
with open(src_json_path, "r", encoding="utf-8") as f:
|
| 176 |
-
src_stoi = json.load(f)
|
| 177 |
-
|
| 178 |
-
with open(tgt_json_path, "r", encoding="utf-8") as f:
|
| 179 |
-
tgt_itos = json.load(f)
|
| 180 |
-
|
| 181 |
# # Load vocabularies
|
| 182 |
-
# with open(
|
| 183 |
# src_stoi = json.load(f)
|
| 184 |
|
| 185 |
-
# with open(
|
| 186 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
|
| 188 |
# Build inverse mapping for target
|
| 189 |
-
|
| 190 |
|
| 191 |
PAD_TOKEN = "<pad>"
|
| 192 |
SOS_TOKEN = "<sos>"
|
|
|
|
| 166 |
# 🔴 CHANGE THIS: your actual model repo id
|
| 167 |
MODEL_REPO = "harishwar017/transliteration_transformer"
|
| 168 |
|
| 169 |
+
# # Download files from HF Hub into the Space’s local cache
|
| 170 |
+
# src_json_path = hf_hub_download(repo_id=MODEL_REPO, filename="src_stoi.json")
|
| 171 |
+
# tgt_json_path = hf_hub_download(repo_id=MODEL_REPO, filename="tgt_stoi.json")
|
| 172 |
model_path = hf_hub_download(repo_id=MODEL_REPO, filename="best_hindi_roman_transformer.pt")
|
| 173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
# # Load vocabularies
|
| 175 |
+
# with open(src_json_path, "r", encoding="utf-8") as f:
|
| 176 |
# src_stoi = json.load(f)
|
| 177 |
|
| 178 |
+
# with open(tgt_json_path, "r", encoding="utf-8") as f:
|
| 179 |
+
# tgt_itos = json.load(f)
|
| 180 |
+
|
| 181 |
+
# Load vocabularies
|
| 182 |
+
with open("src_stoi.json", "r", encoding="utf-8") as f:
|
| 183 |
+
src_stoi = json.load(f)
|
| 184 |
+
|
| 185 |
+
with open("tgt_stoi.json", "r", encoding="utf-8") as f:
|
| 186 |
+
tgt_stoi = json.load(f)
|
| 187 |
|
| 188 |
# Build inverse mapping for target
|
| 189 |
+
tgt_itos = {int(v): k for k, v in tgt_stoi.items()} # keys might be strings in JSON
|
| 190 |
|
| 191 |
PAD_TOKEN = "<pad>"
|
| 192 |
SOS_TOKEN = "<sos>"
|