Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,10 +4,13 @@ from visualcloze import VisualClozeModel
|
|
| 4 |
import gradio as gr
|
| 5 |
import examples
|
| 6 |
import torch
|
|
|
|
| 7 |
from functools import partial
|
| 8 |
from data.prefix_instruction import get_layout_instruction
|
| 9 |
from huggingface_hub import snapshot_download
|
| 10 |
|
|
|
|
|
|
|
| 11 |
|
| 12 |
max_grid_h = 5
|
| 13 |
max_grid_w = 5
|
|
@@ -463,13 +466,28 @@ def parse_args():
|
|
| 463 |
if __name__ == "__main__":
|
| 464 |
args = parse_args()
|
| 465 |
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 470 |
|
| 471 |
# Create Gradio demo
|
| 472 |
demo = create_demo(model)
|
| 473 |
|
| 474 |
# Start Gradio server
|
| 475 |
-
demo.launch()
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
import examples
|
| 6 |
import torch
|
| 7 |
+
import os # ์ถ๊ฐ๋ import
|
| 8 |
from functools import partial
|
| 9 |
from data.prefix_instruction import get_layout_instruction
|
| 10 |
from huggingface_hub import snapshot_download
|
| 11 |
|
| 12 |
+
# Xet ์คํ ๋ฆฌ์ง ๋นํ์ฑํ (์ค๋ฅ ํด๊ฒฐ)
|
| 13 |
+
os.environ["HF_HUB_ENABLE_XET_BACKEND"] = "0"
|
| 14 |
|
| 15 |
max_grid_h = 5
|
| 16 |
max_grid_w = 5
|
|
|
|
| 466 |
if __name__ == "__main__":
|
| 467 |
args = parse_args()
|
| 468 |
|
| 469 |
+
# ๋ชจ๋ธ ๋ค์ด๋ก๋ ๋ถ๋ถ ์๋ฌ ์ฒ๋ฆฌ (์ค๋ฅ ํด๊ฒฐ)
|
| 470 |
+
try:
|
| 471 |
+
snapshot_download(repo_id="VisualCloze/VisualCloze", repo_type="model", local_dir="checkpoints")
|
| 472 |
+
except Exception as e:
|
| 473 |
+
print(f"๋ชจ๋ธ ๋ค์ด๋ก๋ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}")
|
| 474 |
+
print("์ฒดํฌํฌ์ธํธ ๋๋ ํ ๋ฆฌ๋ฅผ ํ์ธํฉ๋๋ค...")
|
| 475 |
+
if not os.path.exists("checkpoints"):
|
| 476 |
+
os.makedirs("checkpoints")
|
| 477 |
+
print("checkpoints ๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํ์ต๋๋ค.")
|
| 478 |
+
|
| 479 |
+
# ๋ชจ๋ธ ์ด๊ธฐํ ๋ถ๋ถ ์๋ฌ ์ฒ๋ฆฌ (์ค๋ฅ ํด๊ฒฐ)
|
| 480 |
+
try:
|
| 481 |
+
model = VisualClozeModel(resolution=args.resolution, model_path=args.model_path, precision=args.precision)
|
| 482 |
+
except Exception as e:
|
| 483 |
+
print(f"๋ชจ๋ธ ์ด๊ธฐํ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}")
|
| 484 |
+
print("์ด ์ค๋ฅ๋ฅผ ํด๊ฒฐํ๋ ค๋ฉด models/util.py ํ์ผ์ load_t5 ํจ์๋ฅผ ์์ ํด์ผ ํฉ๋๋ค.")
|
| 485 |
+
# ์ฌ๊ธฐ์๋ ํ๋ก๊ทธ๋จ์ ์ข
๋ฃํ์ง ์๊ณ , ์ค๋ฅ๋ฅผ ํ์๋ง ํฉ๋๋ค.
|
| 486 |
+
# ์ค์ ๋ก๋ ์ฌ๊ธฐ์ ํ๋ก๊ทธ๋จ์ด ์ข
๋ฃ๋๊ฒ ์ง๋ง, ์ฌ์ฉ์์๊ฒ ํ์ํ ์ ๋ณด๋ฅผ ์ ๊ณตํ๊ธฐ ์ํด ์ค๋ฅ ๋ฉ์์ง๋ฅผ ์ถ๋ ฅํฉ๋๋ค.
|
| 487 |
+
raise
|
| 488 |
|
| 489 |
# Create Gradio demo
|
| 490 |
demo = create_demo(model)
|
| 491 |
|
| 492 |
# Start Gradio server
|
| 493 |
+
demo.launch()
|