Spaces:
Running
on
L40S
Running
on
L40S
Update app.py
Browse files
app.py
CHANGED
@@ -313,39 +313,52 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
313 |
)
|
314 |
|
315 |
if __name__ == "__main__":
|
316 |
-
#
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
|
|
|
|
|
|
|
|
334 |
"ByteDance/Hyper-SD",
|
335 |
"Hyper-FLUX.1-dev-8steps-lora.safetensors",
|
336 |
-
|
337 |
)
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
|
351 |
-
|
|
|
|
|
|
313 |
)
|
314 |
|
315 |
if __name__ == "__main__":
|
316 |
+
# CUDA ์ฌ์ฉ ๊ฐ๋ฅ ์ฌ๋ถ ํ์ธ
|
317 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
318 |
+
print(f"Using device: {device}")
|
319 |
+
|
320 |
+
try:
|
321 |
+
# 3D ์์ฑ ํ์ดํ๋ผ์ธ
|
322 |
+
pipeline = TrellisImageTo3DPipeline.from_pretrained(
|
323 |
+
"JeffreyXiang/TRELLIS-image-large",
|
324 |
+
token=HF_TOKEN # use_auth_token ๋์ token ์ฌ์ฉ
|
325 |
+
)
|
326 |
+
pipeline.to(device)
|
327 |
+
|
328 |
+
# ์ด๋ฏธ์ง ์์ฑ ํ์ดํ๋ผ์ธ
|
329 |
+
pipe = FluxPipeline.from_pretrained(
|
330 |
+
"black-forest-labs/FLUX.1-dev",
|
331 |
+
torch_dtype=torch.bfloat16,
|
332 |
+
token=HF_TOKEN, # use_auth_token ๋์ token ์ฌ์ฉ
|
333 |
+
device_map="auto"
|
334 |
+
)
|
335 |
+
|
336 |
+
# Hyper-SD LoRA ๋ก๋
|
337 |
+
lora_path = hf_hub_download(
|
338 |
"ByteDance/Hyper-SD",
|
339 |
"Hyper-FLUX.1-dev-8steps-lora.safetensors",
|
340 |
+
token=HF_TOKEN # use_auth_token ๋์ token ์ฌ์ฉ
|
341 |
)
|
342 |
+
pipe.load_lora_weights(lora_path)
|
343 |
+
pipe.fuse_lora(lora_scale=0.125)
|
344 |
+
|
345 |
+
# ๋ฒ์ญ๊ธฐ ์ด๊ธฐํ
|
346 |
+
translator = pipeline(
|
347 |
+
"translation",
|
348 |
+
model="Helsinki-NLP/opus-mt-ko-en",
|
349 |
+
device=0 if torch.cuda.is_available() else -1
|
350 |
+
)
|
351 |
+
|
352 |
+
# ์ด๊ธฐ ์ด๋ฏธ์ง ์ ์ฒ๋ฆฌ ํ
์คํธ
|
353 |
+
try:
|
354 |
+
test_image = Image.fromarray(np.zeros((512, 512, 3), dtype=np.uint8))
|
355 |
+
pipeline.preprocess_image(test_image)
|
356 |
+
except Exception as e:
|
357 |
+
print(f"Warning: Initial preprocessing test failed: {e}")
|
358 |
+
|
359 |
+
# Gradio ์ธํฐํ์ด์ค ์คํ
|
360 |
+
demo.launch(allowed_paths=[PERSISTENT_DIR])
|
361 |
|
362 |
+
except Exception as e:
|
363 |
+
print(f"Error during initialization: {e}")
|
364 |
+
raise
|