8000 GDMP for web by j20001970 · Pull Request #23 · j20001970/GDMP · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

GDMP for web #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/build-web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 🌐 Build Web
on: [workflow_call, workflow_dispatch]

jobs:
build:
name: Web WebAssembly
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.9"

- name: Setup
run: |
python ./setup.py

- name: Build
run: |
source ./venv/bin/activate
python ./build.py web --type release --output build/

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifact-web
path: |
build/*.wasm*
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ jobs:
build-ios:
name: 🍏 Build iOS
uses: ./.github/workflows/build-ios.yml

# Build the Web Artifacts
build-web:
name: 🌐 Build Web
uses: ./.github/workflows/build-web.yml
8000
12 changes: 8 additions & 4 deletions GDMP/GDMP.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ DATA = [
TASKS = [
"//GDMP/tasks/vision:face_detector",
"//GDMP/tasks/vision:face_landmarker",
"//GDMP/tasks/vision:face_stylizer",
"//GDMP/tasks/vision:gesture_recognizer",
"//GDMP/tasks/vision:hand_landmarker",
"//GDMP/tasks/vision:holistic_landmarker",
"//GDMP/tasks/vision:image_classifier",
"//GDMP/tasks/vision:image_embedder",
"//GDMP/tasks/vision:image_segmenter",
"//GDMP/tasks/vision:interactive_segmenter",
"//GDMP/tasks/vision:object_detector",
"//GDMP/tasks/vision:pose_landmarker",
]
] + select({
"@platforms//os:emscripten": [],
"//conditions:default": [
"//GDMP/tasks/vision:face_stylizer",
"//GDMP/tasks/vision:image_segmenter",
"//GDMP/tasks/vision:interactive_segmenter",
],
})
18 changes: 18 additions & 0 deletions GDMP/web/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
load("@emsdk//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary")

cc_binary(
name = "web",
linkopts = [
"-sSIDE_MODULE=1",
"-sSUPPORT_LONGJMP='wasm'",
"-sWASM_BIGINT",
"--oformat=wasm",
],
deps = ["//GDMP"],
)

wasm_cc_binary(
name = "GDMP",
cc_target = ":web",
outputs = ["GDMP.wasm"],
)
1 change: 1 addition & 0 deletions addons/GDMP/GDMP.gdextension
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ macos.arm64 = "res://addons/GDMP/libs/arm64/libGDMP.macos.dylib"
macos.x86_64 = "res://addons/GDMP/libs/x86_64/libGDMP.macos.dylib"
windows.x86_64 = "res://addons/GDMP/libs/x86_64/GDMP.windows.dll"
ios = "res://addons/GDMP/libs/GDMP.ios.framework"
web = "res://addons/GDMP/libs/GDMP.web.wasm"

[dependencies]

Expand Down
20 changes: 20 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"android": "@GDMP//GDMP/android:GDMP",
"desktop": "@GDMP//GDMP/desktop:GDMP",
"ios": "@GDMP//GDMP/ios:GDMP",
"web": "@GDMP//GDMP/web:GDMP",
}

TARGET_ARGS = {
Expand All @@ -44,6 +45,17 @@
"--apple_generate_dsym=false",
"--config=ios",
],
"web": [
"--incompatible_enable_cc_toolchain_resolution",
"--crosstool_top=@emsdk//emscripten_toolchain:everything",
"--host_crosstool_top=@bazel_tools//tools/cpp:toolchain",
"--copt=-sSIDE_MODULE=1",
"--copt=-sSUPPORT_LONGJMP='wasm'",
"--copt=-pthread",
"--define=MEDIAPIPE_DISABLE_GPU=1",
"--define=MEDIAPIPE_DISABLE_OPENCV=1",
"--define=MEDIAPIPE_ENABLE_HALIDE=1",
],
}


Expand Down Expand Up @@ -202,6 +214,13 @@ def copy_ios(args: Namespace):
f.extractall(output)


def copy_web(args: Namespace):
output: str = args.output
src = path.join(MEDIAPIPE_DIR, "bazel-bin/external/GDMP/GDMP/web/GDMP.wasm")
dst = path.join(output, "GDMP.web.wasm")
copyfile(src, dst)


def copy_output(args: Namespace):
target: str = args.target
output: str = args.output
Expand All @@ -212,6 +231,7 @@ def copy_output(args: Namespace):
"android": copy_android,
"desktop": copy_desktop,
"ios": copy_ios,
"web": copy_web,
}
copy_actions[target](args)

Expand Down
0