Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -632,40 +632,39 @@ def build_demo(embed_mode, cur_dir=None, concurrency_count=10):
|
|
| 632 |
return demo
|
| 633 |
|
| 634 |
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
|
| 664 |
-
|
| 665 |
-
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
|
| 669 |
-
|
| 670 |
-
|
| 671 |
-
)
|
|
|
|
| 632 |
return demo
|
| 633 |
|
| 634 |
|
| 635 |
+
parser = argparse.ArgumentParser()
|
| 636 |
+
parser.add_argument("--host", type=str, default="0.0.0.0")
|
| 637 |
+
parser.add_argument("--port", type=int)
|
| 638 |
+
parser.add_argument("--concurrency-count", type=int, default=5)
|
| 639 |
+
parser.add_argument("--share", action="store_true")
|
| 640 |
+
parser.add_argument("--moderate", action="store_true")
|
| 641 |
+
parser.add_argument("--embed", action="store_true")
|
| 642 |
+
args = parser.parse_args()
|
| 643 |
+
|
| 644 |
+
# Create log directory if it doesn't exist
|
| 645 |
+
os.makedirs(LOGDIR, exist_ok=True)
|
| 646 |
+
|
| 647 |
+
# GPU Check
|
| 648 |
+
if torch.cuda.is_available():
|
| 649 |
+
logger.info(f"CUDA available with {torch.cuda.device_count()} devices")
|
| 650 |
+
else:
|
| 651 |
+
logger.warning("CUDA not available! Models will run on CPU which may be very slow.")
|
| 652 |
+
|
| 653 |
+
# Hugging Face token handling
|
| 654 |
+
api_key = os.getenv("token")
|
| 655 |
+
if api_key:
|
| 656 |
+
from huggingface_hub import login
|
| 657 |
+
|
| 658 |
+
login(token=api_key)
|
| 659 |
+
logger.info("Logged in to Hugging Face Hub")
|
| 660 |
+
|
| 661 |
+
|
| 662 |
+
demo = build_demo(embed_mode=args.embed, cur_dir='./', concurrency_count=args.concurrency_count)
|
| 663 |
+
demo.queue(
|
| 664 |
+
status_update_rate=10,
|
| 665 |
+
api_open=False
|
| 666 |
+
).launch(
|
| 667 |
+
server_name=args.host,
|
| 668 |
+
server_port=args.port,
|
| 669 |
+
share=args.share
|
| 670 |
+
)
|
|
|