Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import os
|
| 2 |
import base64
|
|
|
|
| 3 |
import tempfile
|
| 4 |
from queue import Queue
|
| 5 |
import threading
|
|
@@ -91,6 +92,14 @@ def env_flag(name: str, default: bool = False) -> bool:
|
|
| 91 |
ENABLE_MODEL_WARMUP = env_flag("NOTEWORTHY_WARMUP", True)
|
| 92 |
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
def _order_points(points):
|
| 95 |
import numpy as np
|
| 96 |
|
|
@@ -623,11 +632,15 @@ if HAS_SPACES:
|
|
| 623 |
predict_all = spaces.GPU(duration=180)(predict_all)
|
| 624 |
|
| 625 |
|
| 626 |
-
|
| 627 |
-
title
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 631 |
gr.Markdown(
|
| 632 |
"""
|
| 633 |
# Noteworthy
|
|
@@ -690,9 +703,15 @@ with gr.Blocks(
|
|
| 690 |
],
|
| 691 |
)
|
| 692 |
|
| 693 |
-
|
| 694 |
-
theme
|
| 695 |
-
server_name
|
| 696 |
-
server_port
|
| 697 |
-
share
|
| 698 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import base64
|
| 3 |
+
import inspect
|
| 4 |
import tempfile
|
| 5 |
from queue import Queue
|
| 6 |
import threading
|
|
|
|
| 92 |
ENABLE_MODEL_WARMUP = env_flag("NOTEWORTHY_WARMUP", True)
|
| 93 |
|
| 94 |
|
| 95 |
+
def supports_keyword(callable_obj, keyword):
|
| 96 |
+
try:
|
| 97 |
+
signature = inspect.signature(callable_obj)
|
| 98 |
+
except (TypeError, ValueError):
|
| 99 |
+
return False
|
| 100 |
+
return keyword in signature.parameters
|
| 101 |
+
|
| 102 |
+
|
| 103 |
def _order_points(points):
|
| 104 |
import numpy as np
|
| 105 |
|
|
|
|
| 632 |
predict_all = spaces.GPU(duration=180)(predict_all)
|
| 633 |
|
| 634 |
|
| 635 |
+
blocks_kwargs = {
|
| 636 |
+
"title": "Noteworthy — Sheet Music Transcription",
|
| 637 |
+
}
|
| 638 |
+
if supports_keyword(gr.Blocks, "css"):
|
| 639 |
+
blocks_kwargs["css"] = CUSTOM_CSS
|
| 640 |
+
if supports_keyword(gr.Blocks, "js"):
|
| 641 |
+
blocks_kwargs["js"] = CAMERA_CAPTURE_JS
|
| 642 |
+
|
| 643 |
+
with gr.Blocks(**blocks_kwargs) as demo:
|
| 644 |
gr.Markdown(
|
| 645 |
"""
|
| 646 |
# Noteworthy
|
|
|
|
| 703 |
],
|
| 704 |
)
|
| 705 |
|
| 706 |
+
launch_kwargs = {
|
| 707 |
+
"theme": gr.themes.Soft(),
|
| 708 |
+
"server_name": os.environ.get("GRADIO_SERVER_NAME", "0.0.0.0"),
|
| 709 |
+
"server_port": int(os.environ.get("GRADIO_SERVER_PORT", "7860")),
|
| 710 |
+
"share": env_flag("GRADIO_SHARE"),
|
| 711 |
+
}
|
| 712 |
+
if supports_keyword(demo.launch, "css"):
|
| 713 |
+
launch_kwargs["css"] = CUSTOM_CSS
|
| 714 |
+
if supports_keyword(demo.launch, "js"):
|
| 715 |
+
launch_kwargs["js"] = CAMERA_CAPTURE_JS
|
| 716 |
+
|
| 717 |
+
demo.launch(**launch_kwargs)
|