Spaces:
Paused
Paused
hanging changes
Browse files
app.py
CHANGED
|
@@ -13,48 +13,48 @@ import sys, pathlib
|
|
| 13 |
import os
|
| 14 |
os.environ["OPENAI_API_KEY"] = "test"
|
| 15 |
|
| 16 |
-
|
| 17 |
-
repo_dir = snapshot_download(repo_id="KevinX-Penn28/testing", revision="main")
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
if module_name == VINE_PACKAGE or module_name.startswith(f"{VINE_PACKAGE}."):
|
| 25 |
-
del sys.modules[module_name]
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
vine_pipeline_module = importlib.import_module(f"{VINE_PACKAGE}.vine_pipeline")
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
VinePipeline = vine_pipeline_module.VinePipeline
|
| 47 |
|
| 48 |
-
current_dir = Path(__file__).parent
|
| 49 |
-
sam_config_path = "//" + str(current_dir / "sam2_hiera_t.yaml")
|
| 50 |
-
sam_checkpoint_path = "//" + str(current_dir / "sam2_hiera_tiny.pt")
|
| 51 |
-
gd_config_path = "//" + str(current_dir / "GroundingDINO_SwinT_OGC.py")
|
| 52 |
-
gd_checkpoint_path = "//" + str(current_dir / "groundingdino_swint_ogc.pth")
|
| 53 |
-
visualization_dir = "//" + str(current_dir / "outputs")
|
| 54 |
|
| 55 |
#@spaces.GPU(duration=200)
|
| 56 |
def process_video(video_file, categorical_keywords, unary_keywords, binary_keywords, object_pairs, output_fps):
|
| 57 |
log_buffer = io.StringIO()
|
|
|
|
| 58 |
try:
|
| 59 |
with contextlib.redirect_stdout(log_buffer), contextlib.redirect_stderr(log_buffer):
|
| 60 |
categorical_keywords = [kw.strip() for kw in categorical_keywords.split(",")] if categorical_keywords else []
|
|
|
|
| 13 |
import os
|
| 14 |
os.environ["OPENAI_API_KEY"] = "test"
|
| 15 |
|
| 16 |
+
print("=== VINE SPACE DEBUG START ===")
|
|
|
|
| 17 |
|
| 18 |
+
os.environ.setdefault("OMP_NUM_THREADS", "1")
|
| 19 |
+
os.environ.setdefault("TOKENIZERS_PARALLELISM", "false")
|
| 20 |
|
| 21 |
+
print("Step 1: Loading Vine repo lazily...")
|
| 22 |
+
VineConfig = VineModel = VinePipeline = None
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
def load_vine():
|
| 25 |
+
global VineConfig, VineModel, VinePipeline
|
| 26 |
+
if VineModel is not None:
|
| 27 |
+
return VineConfig, VineModel, VinePipeline
|
| 28 |
+
|
| 29 |
+
print("Downloading repo...")
|
| 30 |
+
repo_dir = snapshot_download(repo_id="KevinX-Penn28/testing", revision="main")
|
| 31 |
+
|
| 32 |
+
print("Importing modules...")
|
| 33 |
+
package_spec = importlib.util.spec_from_file_location(
|
| 34 |
+
VINE_PACKAGE,
|
| 35 |
+
Path(repo_dir) / "__init__.py",
|
| 36 |
+
submodule_search_locations=[str(repo_dir)],
|
| 37 |
+
)
|
| 38 |
+
package_module = importlib.util.module_from_spec(package_spec)
|
| 39 |
+
sys.modules[VINE_PACKAGE] = package_module
|
| 40 |
+
package_spec.loader.exec_module(package_module)
|
| 41 |
|
| 42 |
+
vine_config_module = importlib.import_module(f"{VINE_PACKAGE}.vine_config")
|
| 43 |
+
vine_model_module = importlib.import_module(f"{VINE_PACKAGE}.vine_model")
|
| 44 |
+
vine_pipeline_module = importlib.import_module(f"{VINE_PACKAGE}.vine_pipeline")
|
| 45 |
|
| 46 |
+
VineConfig = vine_config_module.VineConfig
|
| 47 |
+
VineModel = vine_model_module.VineModel
|
| 48 |
+
VinePipeline = vine_pipeline_module.VinePipeline
|
|
|
|
| 49 |
|
| 50 |
+
print("Vine loaded")
|
| 51 |
+
return VineConfig, VineModel, VinePipeline
|
|
|
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
#@spaces.GPU(duration=200)
|
| 55 |
def process_video(video_file, categorical_keywords, unary_keywords, binary_keywords, object_pairs, output_fps):
|
| 56 |
log_buffer = io.StringIO()
|
| 57 |
+
VineConfig, VineModel, VinePipeline = load_vine()
|
| 58 |
try:
|
| 59 |
with contextlib.redirect_stdout(log_buffer), contextlib.redirect_stderr(log_buffer):
|
| 60 |
categorical_keywords = [kw.strip() for kw in categorical_keywords.split(",")] if categorical_keywords else []
|