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
downloading from S3
Browse files- handler.py +3 -9
handler.py
CHANGED
|
@@ -213,21 +213,15 @@ def TemporaryDirectory():
|
|
| 213 |
shutil.rmtree(str(tmpdir))
|
| 214 |
|
| 215 |
|
| 216 |
-
def download_file(
|
| 217 |
-
"""Download file from
|
| 218 |
-
|
| 219 |
-
"Authorization": f"token {GITHUB_TOKEN}",
|
| 220 |
-
"Accept": "application/vnd.github+json",
|
| 221 |
-
}
|
| 222 |
-
authenticated_file_url = f"{github_file_url}?token={GITHUB_TOKEN}"
|
| 223 |
-
with requests.get(authenticated_file_url, headers=headers, stream=True) as r:
|
| 224 |
r.raise_for_status()
|
| 225 |
with open(output_fn, "wb") as f:
|
| 226 |
for chunk in r.iter_content(chunk_size=8192):
|
| 227 |
f.write(chunk)
|
| 228 |
return output_fn
|
| 229 |
|
| 230 |
-
|
| 231 |
def _run_align_script(bo_fn, en_fn, output_dir):
|
| 232 |
start = time.time()
|
| 233 |
cmd = [str(ALIGNER_SCRIPT_PATH), str(bo_fn), str(en_fn), str(output_dir)]
|
|
|
|
| 213 |
shutil.rmtree(str(tmpdir))
|
| 214 |
|
| 215 |
|
| 216 |
+
def download_file(s3_public_url: str, output_fn) -> Path:
|
| 217 |
+
"""Download file from a public S3 bucket URL."""
|
| 218 |
+
with requests.get(s3_public_url, stream=True) as r:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
r.raise_for_status()
|
| 220 |
with open(output_fn, "wb") as f:
|
| 221 |
for chunk in r.iter_content(chunk_size=8192):
|
| 222 |
f.write(chunk)
|
| 223 |
return output_fn
|
| 224 |
|
|
|
|
| 225 |
def _run_align_script(bo_fn, en_fn, output_dir):
|
| 226 |
start = time.time()
|
| 227 |
cmd = [str(ALIGNER_SCRIPT_PATH), str(bo_fn), str(en_fn), str(output_dir)]
|