Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,8 +13,13 @@ from diffusers.utils import export_to_video
|
|
| 13 |
import random
|
| 14 |
from transformers import pipeline
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
# 한글 메뉴 이름 dictionary
|
| 20 |
korean_labels = {
|
|
@@ -36,13 +41,14 @@ korean_labels = {
|
|
| 36 |
"Seed": "시드"
|
| 37 |
}
|
| 38 |
|
| 39 |
-
# load pipelines
|
| 40 |
base_model = "black-forest-labs/FLUX.1-dev"
|
| 41 |
|
| 42 |
-
taef1 = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=torch.bfloat16).to("cuda")
|
| 43 |
pipe = FluxPipeline.from_pretrained(base_model,
|
| 44 |
vae=taef1,
|
| 45 |
-
torch_dtype=torch.bfloat16
|
|
|
|
| 46 |
|
| 47 |
pipe.transformer.to(memory_format=torch.channels_last)
|
| 48 |
#pipe.transformer = torch.compile(pipe.transformer, mode="max-autotune", fullgraph=True)
|
|
@@ -76,7 +82,7 @@ def convert_to_centered_scale(num):
|
|
| 76 |
|
| 77 |
def translate_if_korean(text):
|
| 78 |
if any('\u3131' <= char <= '\u3163' or '\uac00' <= char <= '\ud7a3' for char in text):
|
| 79 |
-
return translator(text)[0]['translation_text']
|
| 80 |
return text
|
| 81 |
|
| 82 |
@spaces.GPU(duration=85)
|
|
|
|
| 13 |
import random
|
| 14 |
from transformers import pipeline
|
| 15 |
|
| 16 |
+
# Hugging Face 토큰 가져오기
|
| 17 |
+
hf_token = os.getenv("HF_TOKEN")
|
| 18 |
+
if not hf_token:
|
| 19 |
+
raise ValueError("HF_TOKEN environment variable is not set. Please set it to your Hugging Face token.")
|
| 20 |
+
|
| 21 |
+
# 번역 모델 로드 (토큰 인증 추가)
|
| 22 |
+
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en", use_auth_token=hf_token)
|
| 23 |
|
| 24 |
# 한글 메뉴 이름 dictionary
|
| 25 |
korean_labels = {
|
|
|
|
| 41 |
"Seed": "시드"
|
| 42 |
}
|
| 43 |
|
| 44 |
+
# load pipelines (토큰 인증 추가)
|
| 45 |
base_model = "black-forest-labs/FLUX.1-dev"
|
| 46 |
|
| 47 |
+
taef1 = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=torch.bfloat16, use_auth_token=hf_token).to("cuda")
|
| 48 |
pipe = FluxPipeline.from_pretrained(base_model,
|
| 49 |
vae=taef1,
|
| 50 |
+
torch_dtype=torch.bfloat16,
|
| 51 |
+
use_auth_token=hf_token)
|
| 52 |
|
| 53 |
pipe.transformer.to(memory_format=torch.channels_last)
|
| 54 |
#pipe.transformer = torch.compile(pipe.transformer, mode="max-autotune", fullgraph=True)
|
|
|
|
| 82 |
|
| 83 |
def translate_if_korean(text):
|
| 84 |
if any('\u3131' <= char <= '\u3163' or '\uac00' <= char <= '\ud7a3' for char in text):
|
| 85 |
+
return translator(text, use_auth_token=hf_token)[0]['translation_text']
|
| 86 |
return text
|
| 87 |
|
| 88 |
@spaces.GPU(duration=85)
|