|
|
import os |
|
|
from ct2_transformers import TransformerConverter |
|
|
|
|
|
|
|
|
model_name = "Helsinki-NLP/opus-mt-tc-big-en-ar" |
|
|
|
|
|
|
|
|
output_dir = "en_ar_ct2_model" |
|
|
|
|
|
|
|
|
if not os.path.exists(output_dir): |
|
|
os.makedirs(output_dir) |
|
|
|
|
|
print(f"Starting conversion of model: {model_name}") |
|
|
print("This may take a few moments...") |
|
|
|
|
|
|
|
|
converter = TransformerConverter(model_name) |
|
|
|
|
|
|
|
|
converter.convert(output_dir, quantization="int8") |
|
|
|
|
|
print(f"\nModel successfully converted and saved to the '{output_dir}' folder.") |
|
|
print("You are now ready to upload this folder to your Hugging Face Space.") |