Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,53 +10,54 @@ from huggingface_hub import snapshot_download
|
|
| 10 |
import sys, pathlib
|
| 11 |
import os
|
| 12 |
os.environ["OPENAI_API_KEY"] = "test"
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
)
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
| 60 |
|
| 61 |
current_dir = Path(__file__).resolve().parent
|
| 62 |
sam_config_path = "/" + str(Path(current_dir) / "sam2_hiera_t.yaml")
|
|
@@ -65,14 +66,14 @@ gd_config_path = "/" + str(Path(current_dir) / "GroundingDINO_SwinT_OGC.py")
|
|
| 65 |
gd_checkpoint_path = "/" + str(Path(current_dir) / "groundingdino_swint_ogc.pth")
|
| 66 |
visualization_dir = "/" + str(Path(current_dir) / "outputs")
|
| 67 |
|
| 68 |
-
# current_dir = Path.cwd()
|
| 69 |
-
# sam_config_path = "/" + str(current_dir / "sam2_hiera_t.yaml")
|
| 70 |
-
# sam_checkpoint_path = "/" + str(current_dir / "sam2_hiera_tiny.pt")
|
| 71 |
-
# gd_config_path = "/" + str(current_dir / "GroundingDINO_SwinT_OGC.py")
|
| 72 |
-
# gd_checkpoint_path = "/" + str(current_dir / "groundingdino_swint_ogc.pth")
|
| 73 |
-
# visualization_dir = "/" + str(current_dir / "outputs")
|
| 74 |
|
| 75 |
-
print(f"Setting up paths done: {sam_config_path}, {sam_checkpoint_path}, {gd_config_path}, {gd_checkpoint_path}")
|
| 76 |
|
| 77 |
def process_video(video_file, categorical_keywords, unary_keywords, binary_keywords, object_pairs, output_fps):
|
| 78 |
|
|
|
|
| 10 |
import sys, pathlib
|
| 11 |
import os
|
| 12 |
os.environ["OPENAI_API_KEY"] = "test"
|
| 13 |
+
from vine_hf import VineConfig, VineModel, VinePipeline
|
| 14 |
+
|
| 15 |
+
# # 1) Download the repo to a local cache dir
|
| 16 |
+
# print("Downloading remote vine repo...")
|
| 17 |
+
# repo_dir = snapshot_download(repo_id="KevinX-Penn28/testing", revision="main")
|
| 18 |
+
|
| 19 |
+
# # 2) Register the snapshot as an importable package
|
| 20 |
+
# VINE_PACKAGE = "vine_remote_repo"
|
| 21 |
+
|
| 22 |
+
# # Drop stale modules in case the script reloads
|
| 23 |
+
# for module_name in list(sys.modules):
|
| 24 |
+
# if module_name == VINE_PACKAGE or module_name.startswith(f"{VINE_PACKAGE}."):
|
| 25 |
+
# del sys.modules[module_name]
|
| 26 |
+
|
| 27 |
+
# print("Dropped stale modules and registering vine package...")
|
| 28 |
+
|
| 29 |
+
# package_spec = importlib.util.spec_from_file_location(
|
| 30 |
+
# VINE_PACKAGE,
|
| 31 |
+
# Path(repo_dir) / "__init__.py",
|
| 32 |
+
# submodule_search_locations=[str(repo_dir)],
|
| 33 |
+
# )
|
| 34 |
+
# if not package_spec or not package_spec.loader:
|
| 35 |
+
# raise ImportError(f"Cannot create package spec for {VINE_PACKAGE} at {repo_dir}")
|
| 36 |
+
|
| 37 |
+
# print("Created package spec, loading module...")
|
| 38 |
+
|
| 39 |
+
# package_module = importlib.util.module_from_spec(package_spec)
|
| 40 |
+
# sys.modules[VINE_PACKAGE] = package_module
|
| 41 |
+
|
| 42 |
+
# try:
|
| 43 |
+
# print("Executing module...")
|
| 44 |
+
# package_spec.loader.exec_module(package_module)
|
| 45 |
+
# print("Module executed successfully!")
|
| 46 |
+
# except Exception as e:
|
| 47 |
+
# print(f"ERROR during module execution: {e}")
|
| 48 |
+
# import traceback
|
| 49 |
+
# traceback.print_exc()
|
| 50 |
+
# raise
|
| 51 |
+
|
| 52 |
+
# # 3) Import and use via the registered package
|
| 53 |
+
# print("Importing vine modules...")
|
| 54 |
+
# vine_config_module = importlib.import_module(f"{VINE_PACKAGE}.vine_config")
|
| 55 |
+
# vine_model_module = importlib.import_module(f"{VINE_PACKAGE}.vine_model")
|
| 56 |
+
# vine_pipeline_module = importlib.import_module(f"{VINE_PACKAGE}.vine_pipeline")
|
| 57 |
+
|
| 58 |
+
# VineConfig = vine_config_module.VineConfig # your config class
|
| 59 |
+
# VineModel = vine_model_module.VineModel # your model class
|
| 60 |
+
# VinePipeline = vine_pipeline_module.VinePipeline
|
| 61 |
|
| 62 |
current_dir = Path(__file__).resolve().parent
|
| 63 |
sam_config_path = "/" + str(Path(current_dir) / "sam2_hiera_t.yaml")
|
|
|
|
| 66 |
gd_checkpoint_path = "/" + str(Path(current_dir) / "groundingdino_swint_ogc.pth")
|
| 67 |
visualization_dir = "/" + str(Path(current_dir) / "outputs")
|
| 68 |
|
| 69 |
+
# # current_dir = Path.cwd()
|
| 70 |
+
# # sam_config_path = "/" + str(current_dir / "sam2_hiera_t.yaml")
|
| 71 |
+
# # sam_checkpoint_path = "/" + str(current_dir / "sam2_hiera_tiny.pt")
|
| 72 |
+
# # gd_config_path = "/" + str(current_dir / "GroundingDINO_SwinT_OGC.py")
|
| 73 |
+
# # gd_checkpoint_path = "/" + str(current_dir / "groundingdino_swint_ogc.pth")
|
| 74 |
+
# # visualization_dir = "/" + str(current_dir / "outputs")
|
| 75 |
|
| 76 |
+
# print(f"Setting up paths done: {sam_config_path}, {sam_checkpoint_path}, {gd_config_path}, {gd_checkpoint_path}")
|
| 77 |
|
| 78 |
def process_video(video_file, categorical_keywords, unary_keywords, binary_keywords, object_pairs, output_fps):
|
| 79 |
|