Slavko Novak
commited on
Commit
·
9827f59
1
Parent(s):
dbc5b70
Translation any to english
Browse files
app.py
CHANGED
|
@@ -6,7 +6,12 @@ from diffusers import AutoPipelineForText2Image, AutoPipelineForImage2Image
|
|
| 6 |
#from diffusers.utils import load_image
|
| 7 |
import torch
|
| 8 |
from PIL import Image
|
|
|
|
|
|
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
modelPath = "stabilityai/sdxl-turbo"
|
| 12 |
|
|
@@ -40,6 +45,7 @@ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance
|
|
| 40 |
seed = random.randint(0, MAX_SEED)
|
| 41 |
|
| 42 |
generator = torch.Generator().manual_seed(seed)
|
|
|
|
| 43 |
|
| 44 |
if use_as_input:
|
| 45 |
print("Image to Image:")
|
|
|
|
| 6 |
#from diffusers.utils import load_image
|
| 7 |
import torch
|
| 8 |
from PIL import Image
|
| 9 |
+
from huggingface_hub import hf_hub_download
|
| 10 |
+
from eSeNTranslate import TranslateFromAny2XModel
|
| 11 |
|
| 12 |
+
# Load translation model(s) (Pipeline)
|
| 13 |
+
fasttextModelPath = hf_hub_download(repo_id="facebook/fasttext-language-identification", filename="model.bin")
|
| 14 |
+
translatePipe = TranslateFromAny2XModel(nllb_model_path="facebook/nllb-200-distilled-600M", fasttext_model_path=fasttextModelPath)
|
| 15 |
|
| 16 |
modelPath = "stabilityai/sdxl-turbo"
|
| 17 |
|
|
|
|
| 45 |
seed = random.randint(0, MAX_SEED)
|
| 46 |
|
| 47 |
generator = torch.Generator().manual_seed(seed)
|
| 48 |
+
prompt = translatePipe.generate(prompt)
|
| 49 |
|
| 50 |
if use_as_input:
|
| 51 |
print("Image to Image:")
|