Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import torch
|
|
| 4 |
from transformers import T5Tokenizer, T5ForConditionalGeneration, AutoTokenizer, AutoModelForSeq2SeqLM, AutoModelForCausalLM, AutoModel, pipeline
|
| 5 |
from transformers import logging as hflogging
|
| 6 |
import languagecodes
|
| 7 |
-
import
|
| 8 |
import polars as pl
|
| 9 |
|
| 10 |
hflogging.set_verbosity_error()
|
|
@@ -75,7 +75,7 @@ class Translators:
|
|
| 75 |
|
| 76 |
def google(self):
|
| 77 |
url = os.environ['GCLIENT'] + f'sl={self.sl}&tl={self.tl}&q={self.input_text}'
|
| 78 |
-
response =
|
| 79 |
return response.json()[0][0][0]
|
| 80 |
|
| 81 |
@classmethod
|
|
@@ -490,16 +490,16 @@ def get_info(model_name: str, sl: str = None, tl: str = None):
|
|
| 490 |
helsinki = '### [Helsinki-NLP](https://huggingface.co/Helsinki-NLP "Helsinki-NLP")'
|
| 491 |
if model_name == "Helsinki-NLP" and sl and tl:
|
| 492 |
url = f'https://huggingface.co/{model_name}/opus-mt-{sl}-{tl}/raw/main/README.md'
|
| 493 |
-
response =
|
| 494 |
if 'Repository not found' in response or 'Invalid username or password' in response:
|
| 495 |
return helsinki
|
| 496 |
return response
|
| 497 |
elif model_name == "Argos":
|
| 498 |
-
return
|
| 499 |
elif model_name == "Google":
|
| 500 |
return "Google Translate Online"
|
| 501 |
else:
|
| 502 |
-
return
|
| 503 |
|
| 504 |
def create_interface():
|
| 505 |
with gr.Blocks() as interface:
|
|
|
|
| 4 |
from transformers import T5Tokenizer, T5ForConditionalGeneration, AutoTokenizer, AutoModelForSeq2SeqLM, AutoModelForCausalLM, AutoModel, pipeline
|
| 5 |
from transformers import logging as hflogging
|
| 6 |
import languagecodes
|
| 7 |
+
import httpx, os
|
| 8 |
import polars as pl
|
| 9 |
|
| 10 |
hflogging.set_verbosity_error()
|
|
|
|
| 75 |
|
| 76 |
def google(self):
|
| 77 |
url = os.environ['GCLIENT'] + f'sl={self.sl}&tl={self.tl}&q={self.input_text}'
|
| 78 |
+
response = httpx.get(url)
|
| 79 |
return response.json()[0][0][0]
|
| 80 |
|
| 81 |
@classmethod
|
|
|
|
| 490 |
helsinki = '### [Helsinki-NLP](https://huggingface.co/Helsinki-NLP "Helsinki-NLP")'
|
| 491 |
if model_name == "Helsinki-NLP" and sl and tl:
|
| 492 |
url = f'https://huggingface.co/{model_name}/opus-mt-{sl}-{tl}/raw/main/README.md'
|
| 493 |
+
response = httpx.get(url).text
|
| 494 |
if 'Repository not found' in response or 'Invalid username or password' in response:
|
| 495 |
return helsinki
|
| 496 |
return response
|
| 497 |
elif model_name == "Argos":
|
| 498 |
+
return httpx.get(f'https://huggingface.co/TiberiuCristianLeon/Argostranslate/raw/main/README.md').text
|
| 499 |
elif model_name == "Google":
|
| 500 |
return "Google Translate Online"
|
| 501 |
else:
|
| 502 |
+
return httpx.get(f'https://huggingface.co/{model_name}/raw/main/README.md').text
|
| 503 |
|
| 504 |
def create_interface():
|
| 505 |
with gr.Blocks() as interface:
|