Instructions to use openpecha/aligner with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openpecha/aligner with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("openpecha/aligner") model = AutoModelForSeq2SeqLM.from_pretrained("openpecha/aligner", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update handler.py
Browse files- handler.py +24 -2
handler.py
CHANGED
|
@@ -250,11 +250,33 @@ def _run_align_script(bo_fn, en_fn, output_dir):
|
|
| 250 |
cwd=str(ALIGNER_SCRIPT_DIR),
|
| 251 |
)
|
| 252 |
logging.info(f"Content length of output: {output.stdout} characters")
|
| 253 |
-
|
| 254 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
end = time.time()
|
| 256 |
total_time = round((end - start) / 60, 2)
|
| 257 |
logging.info(f"Total time taken for Aligning: {total_time} mins")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
return output_fn
|
| 259 |
def align(text_pair):
|
| 260 |
|
|
|
|
| 250 |
cwd=str(ALIGNER_SCRIPT_DIR),
|
| 251 |
)
|
| 252 |
logging.info(f"Content length of output: {output.stdout} characters")
|
| 253 |
+
|
| 254 |
+
match = re.search(r"\[OUTPUT\] (.*)", output.stdout)
|
| 255 |
+
if not match:
|
| 256 |
+
logging.error("Failed to find output file path in script output.")
|
| 257 |
+
return None
|
| 258 |
+
|
| 259 |
+
output_fn = match.group(1).strip()
|
| 260 |
+
# Normalize the file path
|
| 261 |
+
output_fn = Path(output_fn)
|
| 262 |
+
|
| 263 |
end = time.time()
|
| 264 |
total_time = round((end - start) / 60, 2)
|
| 265 |
logging.info(f"Total time taken for Aligning: {total_time} mins")
|
| 266 |
+
|
| 267 |
+
# Read and log the contents of the output file
|
| 268 |
+
try:
|
| 269 |
+
if output_fn.exists():
|
| 270 |
+
content = output_fn.read_text()
|
| 271 |
+
if content:
|
| 272 |
+
logging.info(f"First 100 characters of {output_fn}: {content[:100]}...")
|
| 273 |
+
else:
|
| 274 |
+
logging.error(f"The file {output_fn} is empty.")
|
| 275 |
+
else:
|
| 276 |
+
logging.error(f"The file {output_fn} does not exist.")
|
| 277 |
+
except Exception as e:
|
| 278 |
+
logging.error(f"Error reading file {output_fn}: {e}")
|
| 279 |
+
|
| 280 |
return output_fn
|
| 281 |
def align(text_pair):
|
| 282 |
|