yootd 0.2.33 → 0.2.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils/script.d.ts +1 -0
- package/dist/utils/script.js +40 -0
- package/dist/video-player/index.js +57 -87
- package/package.json +4 -4
@@ -0,0 +1 @@
|
|
1
|
+
export declare const loadScript: (url: string) => Promise<void>;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
3
|
+
export var loadScript = /*#__PURE__*/function () {
|
4
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
|
5
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
6
|
+
while (1) switch (_context.prev = _context.next) {
|
7
|
+
case 0:
|
8
|
+
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
9
|
+
// 检查是否已经存在
|
10
|
+
var scripts = document.head.querySelectorAll('script');
|
11
|
+
if (scripts != null && scripts.length > 0) {
|
12
|
+
var arr = Array.from(scripts);
|
13
|
+
if (arr.findIndex(function (item) {
|
14
|
+
return item.src === url;
|
15
|
+
}) != -1) {
|
16
|
+
resolve();
|
17
|
+
return;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
var script = document.createElement('script');
|
21
|
+
script.src = url;
|
22
|
+
script.onload = function () {
|
23
|
+
resolve();
|
24
|
+
};
|
25
|
+
script.onerror = function (e) {
|
26
|
+
reject(e);
|
27
|
+
};
|
28
|
+
console.log("document.head", document.head);
|
29
|
+
document.head.appendChild(script);
|
30
|
+
}));
|
31
|
+
case 1:
|
32
|
+
case "end":
|
33
|
+
return _context.stop();
|
34
|
+
}
|
35
|
+
}, _callee);
|
36
|
+
}));
|
37
|
+
return function loadScript(_x) {
|
38
|
+
return _ref.apply(this, arguments);
|
39
|
+
};
|
40
|
+
}();
|
@@ -4,8 +4,6 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
4
|
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
5
5
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
6
6
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
7
|
-
console.log('process.env', process.env.NODE_ENV);
|
8
|
-
var isDev = process.env.NODE_ENV === 'development';
|
9
7
|
// import * as faceapi from '@vladmandic/face-api';
|
10
8
|
//
|
11
9
|
// import * as posedetection from '@tensorflow-models/pose-detection';
|
@@ -20,6 +18,7 @@ import { Spin } from "./..";
|
|
20
18
|
import { useBaseURL } from "../hooks/useBaseURL";
|
21
19
|
import { useOSS } from "../hooks/useOSS";
|
22
20
|
import { useRequest } from "../hooks/useRequest";
|
21
|
+
import { loadScript } from "../utils/script";
|
23
22
|
import controlBottomBg from "./assets/control-background.png";
|
24
23
|
var PROGRESS_BAR_HEIGHT = 63;
|
25
24
|
var MIN_SCORE = 0.5; // minimum score
|
@@ -824,105 +823,76 @@ export var VideoPlayer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
824
823
|
case 2:
|
825
824
|
_context3.prev = 2;
|
826
825
|
if (!((aiFeature.anchor || aiFeature.emotion || aiFeature.character || aiFeature.pose) && !tfInitialized)) {
|
827
|
-
_context3.next =
|
826
|
+
_context3.next = 13;
|
828
827
|
break;
|
829
828
|
}
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
case 7:
|
837
|
-
_context3.t0 = _context3.sent;
|
838
|
-
_context3.next = 11;
|
839
|
-
break;
|
840
|
-
case 10:
|
841
|
-
_context3.t0 = window.tf;
|
842
|
-
case 11:
|
843
|
-
tf = _context3.t0;
|
844
|
-
_context3.next = 14;
|
829
|
+
_context3.next = 6;
|
830
|
+
return loadScript("".concat(window.location.origin, "/oss/cdn/@tensorflow/tfjs/dist/tf.min.js"));
|
831
|
+
case 6:
|
832
|
+
console.log('window.tf', window.tf);
|
833
|
+
tf = window.tf; // 初始化
|
834
|
+
_context3.next = 10;
|
845
835
|
return tf.setBackend('webgl');
|
846
|
-
case
|
847
|
-
_context3.next =
|
836
|
+
case 10:
|
837
|
+
_context3.next = 12;
|
848
838
|
return tf.ready();
|
849
|
-
case
|
839
|
+
case 12:
|
850
840
|
setTfInitialized(true);
|
851
|
-
case
|
852
|
-
_context3.next =
|
841
|
+
case 13:
|
842
|
+
_context3.next = 18;
|
853
843
|
break;
|
854
|
-
case
|
855
|
-
_context3.prev =
|
856
|
-
_context3.
|
857
|
-
console.error('tensorflow 加载失败: ', _context3.
|
858
|
-
case
|
859
|
-
_context3.prev =
|
844
|
+
case 15:
|
845
|
+
_context3.prev = 15;
|
846
|
+
_context3.t0 = _context3["catch"](2);
|
847
|
+
console.error('tensorflow 加载失败: ', _context3.t0);
|
848
|
+
case 18:
|
849
|
+
_context3.prev = 18;
|
860
850
|
if (!((aiFeature.anchor || aiFeature.emotion || aiFeature.character) && !faceApiInitialized)) {
|
861
|
-
_context3.next =
|
862
|
-
break;
|
863
|
-
}
|
864
|
-
if (!isDev) {
|
865
|
-
_context3.next = 30;
|
851
|
+
_context3.next = 36;
|
866
852
|
break;
|
867
853
|
}
|
868
|
-
_context3.next =
|
869
|
-
return
|
870
|
-
case
|
871
|
-
|
872
|
-
_context3.next =
|
873
|
-
break;
|
874
|
-
case 30:
|
875
|
-
_context3.t2 = window.faceapi;
|
876
|
-
case 31:
|
877
|
-
faceapi = _context3.t2;
|
878
|
-
_context3.next = 34;
|
854
|
+
_context3.next = 22;
|
855
|
+
return loadScript("".concat(window.location.origin, "/oss/cdn/@vladmandic/face-api@1.7.15/dist/face-api.js"));
|
856
|
+
case 22:
|
857
|
+
faceapi = window.faceapi;
|
858
|
+
_context3.next = 25;
|
879
859
|
return faceapi.nets.ssdMobilenetv1.load("".concat(OSS, "/model-zoo/face-api-models/model"));
|
880
|
-
case
|
881
|
-
_context3.next =
|
860
|
+
case 25:
|
861
|
+
_context3.next = 27;
|
882
862
|
return faceapi.nets.ageGenderNet.load("".concat(OSS, "/face-api-models/model"));
|
883
|
-
case
|
884
|
-
_context3.next =
|
863
|
+
case 27:
|
864
|
+
_context3.next = 29;
|
885
865
|
return faceapi.nets.faceLandmark68Net.load("".concat(OSS, "/model-zoo/face-api-models/model"));
|
886
|
-
case
|
887
|
-
_context3.next =
|
866
|
+
case 29:
|
867
|
+
_context3.next = 31;
|
888
868
|
return faceapi.nets.faceRecognitionNet.load("".concat(OSS, "/model-zoo/face-api-models/model"));
|
889
|
-
case
|
890
|
-
_context3.next =
|
869
|
+
case 31:
|
870
|
+
_context3.next = 33;
|
891
871
|
return faceapi.nets.faceExpressionNet.load("".concat(OSS, "/model-zoo/face-api-models/model"));
|
892
|
-
case
|
872
|
+
case 33:
|
893
873
|
setOptions(new faceapi.SsdMobilenetv1Options({
|
894
874
|
minConfidence: MIN_SCORE,
|
895
875
|
maxResults: MAX_RESULTS
|
896
876
|
}));
|
897
877
|
detectAllFacesRef.current = faceapi.detectAllFaces;
|
898
878
|
setFaceApiInitialized(true);
|
899
|
-
case
|
900
|
-
_context3.next =
|
879
|
+
case 36:
|
880
|
+
_context3.next = 41;
|
901
881
|
break;
|
902
|
-
case
|
903
|
-
_context3.prev =
|
904
|
-
_context3.
|
905
|
-
console.error('faceapi 加载失败: ', _context3.
|
906
|
-
case
|
907
|
-
_context3.prev =
|
882
|
+
case 38:
|
883
|
+
_context3.prev = 38;
|
884
|
+
_context3.t1 = _context3["catch"](18);
|
885
|
+
console.error('faceapi 加载失败: ', _context3.t1);
|
886
|
+
case 41:
|
887
|
+
_context3.prev = 41;
|
908
888
|
if (!(aiFeature.pose && poseDetector == null)) {
|
909
|
-
_context3.next =
|
889
|
+
_context3.next = 52;
|
910
890
|
break;
|
911
891
|
}
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
_context3.next = 55;
|
917
|
-
return import('@tensorflow-models/pose-detection');
|
918
|
-
case 55:
|
919
|
-
_context3.t4 = _context3.sent;
|
920
|
-
_context3.next = 59;
|
921
|
-
break;
|
922
|
-
case 58:
|
923
|
-
_context3.t4 = window.poseDetection;
|
924
|
-
case 59:
|
925
|
-
poseDetection = _context3.t4;
|
892
|
+
_context3.next = 45;
|
893
|
+
return loadScript("".concat(window.location.origin, "/oss/cdn/@tensorflow-models/pose-detection@2.1.3/dist/pose-detection.min.js"));
|
894
|
+
case 45:
|
895
|
+
poseDetection = window.poseDetection;
|
926
896
|
detectorConfig = {
|
927
897
|
modelType: poseDetection.movenet.modelType.MULTIPOSE_LIGHTNING,
|
928
898
|
enableTracking: true,
|
@@ -930,24 +900,24 @@ export var VideoPlayer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
930
900
|
scoreThreshold: 0.3,
|
931
901
|
modelUrl: "".concat(OSS, "/model-zoo/pose-detection-models/model.json")
|
932
902
|
};
|
933
|
-
_context3.next =
|
903
|
+
_context3.next = 49;
|
934
904
|
return poseDetection.createDetector(poseDetection.SupportedModels.MoveNet, detectorConfig);
|
935
|
-
case
|
905
|
+
case 49:
|
936
906
|
_poseDetector = _context3.sent;
|
937
907
|
getAdjacentPairsRef.current = poseDetection.util.getAdjacentPairs;
|
938
908
|
setPoseDetector(_poseDetector);
|
939
|
-
case
|
940
|
-
_context3.next =
|
909
|
+
case 52:
|
910
|
+
_context3.next = 57;
|
941
911
|
break;
|
942
|
-
case
|
943
|
-
_context3.prev =
|
944
|
-
_context3.
|
945
|
-
console.error('pose detection 加载失败: ', _context3.
|
946
|
-
case
|
912
|
+
case 54:
|
913
|
+
_context3.prev = 54;
|
914
|
+
_context3.t2 = _context3["catch"](41);
|
915
|
+
console.error('pose detection 加载失败: ', _context3.t2);
|
916
|
+
case 57:
|
947
917
|
case "end":
|
948
918
|
return _context3.stop();
|
949
919
|
}
|
950
|
-
}, _callee3, null, [[2,
|
920
|
+
}, _callee3, null, [[2, 15], [18, 38], [41, 54]]);
|
951
921
|
}))();
|
952
922
|
return function () {
|
953
923
|
loaded = false;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "yootd",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.35",
|
4
4
|
"description": "基于 Antd 二次开发的组件库",
|
5
5
|
"license": "MIT",
|
6
6
|
"sideEffects": [
|
@@ -54,10 +54,13 @@
|
|
54
54
|
"devDependencies": {
|
55
55
|
"@commitlint/cli": "^17.1.2",
|
56
56
|
"@commitlint/config-conventional": "^17.1.0",
|
57
|
+
"@tensorflow-models/pose-detection": ">=2.1.3",
|
58
|
+
"@tensorflow/tfjs": ">=4.22.0",
|
57
59
|
"@types/lodash": "^4.17.12",
|
58
60
|
"@types/react": "^18.0.0",
|
59
61
|
"@types/react-dom": "^18.0.0",
|
60
62
|
"@umijs/lint": "^4.0.0",
|
63
|
+
"@vladmandic/face-api": ">=1.7.14",
|
61
64
|
"cross-env": "^10.0.0",
|
62
65
|
"dumi": "^2.3.0",
|
63
66
|
"dumi-theme-antd": "^0.4.2",
|
@@ -77,9 +80,6 @@
|
|
77
80
|
"@dnd-kit/sortable": ">=8.0.0",
|
78
81
|
"@dnd-kit/utilities": ">=3.2.2",
|
79
82
|
"@tanstack/react-query": ">=5.59.15",
|
80
|
-
"@tensorflow-models/pose-detection": ">=2.1.3",
|
81
|
-
"@tensorflow/tfjs": ">=4.22.0",
|
82
|
-
"@vladmandic/face-api": ">=1.7.14",
|
83
83
|
"@xyflow/react": ">=12.3.3",
|
84
84
|
"antd": ">=5.21.4",
|
85
85
|
"axios": ">=1.7.7",
|