Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
# import gradio as gr | |
# from transformers import AutoModelForSeq2SeqLM, AutoTokenizer | |
# model_path = "anzorq/m2m100_418M_ft_ru-kbd_44K" | |
# src_lang="ru" | |
# tgt_lang="zu" | |
# tokenizer = AutoTokenizer.from_pretrained(model_path, src_lang=src_lang) | |
# model = AutoModelForSeq2SeqLM.from_pretrained(model_path) | |
# def translate(text): | |
# inputs = tokenizer(text, return_tensors="pt") | |
# translated_tokens = model.generate( | |
# **inputs, forced_bos_token_id=tokenizer.lang_code_to_id[tgt_lang], num_beams=4, num_return_sequences=4 | |
# ) | |
# translations = [] | |
# for translation in tokenizer.batch_decode(translated_tokens, skip_special_tokens=True): | |
# translations.append(translation) | |
# return translations | |
# output = gr.outputs.Textbox() | |
# iface = gr.Interface(fn=translate, inputs="text", outputs=output) | |
# iface.launch() | |
import gradio as gr | |
title = "Русско-черкесский переводчик" | |
description = """ | |
Demo of a Russian-Circassian (Kabardian dialect) translator. | |
The translator is based on a machine learning model that has been trained on 45,000 Russian-Circassian sentence pairs. | |
It is based on Facebook's <a href="https://about.fb.com/news/2020/10/first-multilingual-machine-translation-model/">M2M-100 model</a>, and can also translate from 100 other languages to Circassian (English, French, Spanish, etc.), but less accurately. | |
The data corpus is constantly being expanded, and we need help in finding sentence sources, OCR, data cleaning, etc. | |
If you are interested in helping out with this project, please contact me at the link below. | |
""" | |
article = """<p style='text-align: center'><a href='https://arxiv.org/abs/1806.00187'>Scaling Neural Machine Translation</a> | <a href='https://github.com/pytorch/fairseq/'>Github Repo</a></p>""" | |
examples = [ | |
["Hello world!"], | |
["PyTorch Hub is a pre-trained model repository designed to facilitate research reproducibility."] | |
] | |
gr.Interface.load("models/anzorq/m2m100_418M_ft_ru-kbd_44K", title=title, description=description, article=article, examples=examples).launch() |