Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -788,14 +788,13 @@ def get_translator(lang):
|
|
| 788 |
translator = pipeline(
|
| 789 |
"translation",
|
| 790 |
model=model_name,
|
| 791 |
-
device="cpu"
|
| 792 |
-
framework="pt"
|
| 793 |
)
|
| 794 |
translators_cache[lang] = translator
|
| 795 |
print(f"Successfully loaded translator for {lang}")
|
| 796 |
except Exception as e:
|
| 797 |
print(f"Error loading translator for {lang}: {e}")
|
| 798 |
-
|
| 799 |
|
| 800 |
return translators_cache[lang]
|
| 801 |
|
|
@@ -819,7 +818,6 @@ def translate_prompt(prompt, source_lang):
|
|
| 819 |
print(f"Translation error for {source_lang}: {e}")
|
| 820 |
return prompt
|
| 821 |
|
| 822 |
-
|
| 823 |
|
| 824 |
def get_translator(lang):
|
| 825 |
if lang == "English":
|
|
@@ -863,6 +861,7 @@ def translate_text(text, translator_info):
|
|
| 863 |
print(f"Translation error: {e}")
|
| 864 |
return text
|
| 865 |
|
|
|
|
| 866 |
@spaces.GPU
|
| 867 |
@torch.no_grad()
|
| 868 |
def generate_image(
|
|
@@ -880,7 +879,6 @@ def generate_image(
|
|
| 880 |
except Exception as e:
|
| 881 |
print(f"Translation failed: {e}")
|
| 882 |
translated_prompt = prompt
|
| 883 |
-
|
| 884 |
|
| 885 |
|
| 886 |
if seed == 0:
|
|
@@ -941,9 +939,6 @@ footer {
|
|
| 941 |
|
| 942 |
def create_demo():
|
| 943 |
with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as demo:
|
| 944 |
-
gr.Markdown("# Multilingual FLUXllama")
|
| 945 |
-
gr.Markdown("### Supported languages: " + ", ".join(["English"] + sorted(list(TRANSLATORS.keys()))))
|
| 946 |
-
|
| 947 |
with gr.Row():
|
| 948 |
with gr.Column():
|
| 949 |
source_lang = gr.Dropdown(
|
|
@@ -956,9 +951,7 @@ def create_demo():
|
|
| 956 |
label="Prompt",
|
| 957 |
value="A beautiful landscape"
|
| 958 |
)
|
| 959 |
-
|
| 960 |
-
|
| 961 |
-
|
| 962 |
width = gr.Slider(minimum=128, maximum=2048, step=64, label="Width", value=768)
|
| 963 |
height = gr.Slider(minimum=128, maximum=2048, step=64, label="Height", value=768)
|
| 964 |
guidance = gr.Slider(minimum=1.0, maximum=5.0, step=0.1, label="Guidance", value=3.5)
|
|
|
|
| 788 |
translator = pipeline(
|
| 789 |
"translation",
|
| 790 |
model=model_name,
|
| 791 |
+
device="cpu" # CPU로 고정
|
|
|
|
| 792 |
)
|
| 793 |
translators_cache[lang] = translator
|
| 794 |
print(f"Successfully loaded translator for {lang}")
|
| 795 |
except Exception as e:
|
| 796 |
print(f"Error loading translator for {lang}: {e}")
|
| 797 |
+
return None
|
| 798 |
|
| 799 |
return translators_cache[lang]
|
| 800 |
|
|
|
|
| 818 |
print(f"Translation error for {source_lang}: {e}")
|
| 819 |
return prompt
|
| 820 |
|
|
|
|
| 821 |
|
| 822 |
def get_translator(lang):
|
| 823 |
if lang == "English":
|
|
|
|
| 861 |
print(f"Translation error: {e}")
|
| 862 |
return text
|
| 863 |
|
| 864 |
+
|
| 865 |
@spaces.GPU
|
| 866 |
@torch.no_grad()
|
| 867 |
def generate_image(
|
|
|
|
| 879 |
except Exception as e:
|
| 880 |
print(f"Translation failed: {e}")
|
| 881 |
translated_prompt = prompt
|
|
|
|
| 882 |
|
| 883 |
|
| 884 |
if seed == 0:
|
|
|
|
| 939 |
|
| 940 |
def create_demo():
|
| 941 |
with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as demo:
|
|
|
|
|
|
|
|
|
|
| 942 |
with gr.Row():
|
| 943 |
with gr.Column():
|
| 944 |
source_lang = gr.Dropdown(
|
|
|
|
| 951 |
label="Prompt",
|
| 952 |
value="A beautiful landscape"
|
| 953 |
)
|
| 954 |
+
|
|
|
|
|
|
|
| 955 |
width = gr.Slider(minimum=128, maximum=2048, step=64, label="Width", value=768)
|
| 956 |
height = gr.Slider(minimum=128, maximum=2048, step=64, label="Height", value=768)
|
| 957 |
guidance = gr.Slider(minimum=1.0, maximum=5.0, step=0.1, label="Guidance", value=3.5)
|