[MF]修复劫持相似链接影响,完善正则匹配
This commit is contained in:
parent
54d3e5798f
commit
00f96caf05
@ -516,19 +516,19 @@
|
||||
// 启动检测循环
|
||||
startDetectionLoop();
|
||||
|
||||
// 尝试从 CDN 加载模型
|
||||
try {
|
||||
const cdnModelUrl = 'https://goood-space-assets.oss-cn-beijing.aliyuncs.com/public/models/hand-knn-model- 2.json';
|
||||
await loadKNNModelData(null, cdnModelUrl);
|
||||
updateStatus('模型加载成功!可以开始游戏了');
|
||||
isModelLoaded = true;
|
||||
startBtn.disabled = false;
|
||||
importModelBtn.disabled = true;
|
||||
} catch (cdnError) {
|
||||
console.warn('CDN 模型加载失败:', cdnError);
|
||||
updateStatus('CDN 模型加载失败,请手动导入模型');
|
||||
importModelBtn.disabled = false;
|
||||
}
|
||||
// // 尝试从 CDN 加载模型
|
||||
// try {
|
||||
// const cdnModelUrl = 'https://goood-space-assets.oss-cn-beijing.aliyuncs.com/public/models/hand-knn-model-2.json';
|
||||
// await loadKNNModelData(null, cdnModelUrl);
|
||||
// updateStatus('模型加载成功!可以开始游戏了');
|
||||
// isModelLoaded = true;
|
||||
// startBtn.disabled = false;
|
||||
// importModelBtn.disabled = true;
|
||||
// } catch (cdnError) {
|
||||
// console.warn('CDN 模型加载失败:', cdnError);
|
||||
// updateStatus('CDN 模型加载失败,请手动导入模型');
|
||||
// importModelBtn.disabled = false;
|
||||
// }
|
||||
|
||||
} catch (error) {
|
||||
console.error('初始化失败:', error);
|
||||
|
@ -573,20 +573,20 @@
|
||||
fileImporter.addEventListener('change', (event) => loadKNNModelData(event.target.files[0]));
|
||||
startStopBtn.addEventListener('click', togglePlaying);
|
||||
|
||||
// 尝试从 CDN 加载模型
|
||||
try {
|
||||
const cdnJsonUrl = 'https://goood-space-assets.oss-cn-beijing.aliyuncs.com/public/models/hand-knn-model.json';
|
||||
await loadKNNModelData(null, cdnJsonUrl);
|
||||
updateGlobalStatus('CDN 手势识别模型加载成功!');
|
||||
isModelLoaded = true;
|
||||
importModelBtn.disabled = true;
|
||||
startStopBtn.disabled = false;
|
||||
} catch (cdnError) {
|
||||
console.warn('CDN 模型加载失败:', cdnError);
|
||||
updateGlobalStatus('请手动导入模型文件');
|
||||
importModelBtn.disabled = false;
|
||||
startStopBtn.disabled = true;
|
||||
}
|
||||
// // 尝试从 CDN 加载模型
|
||||
// try {
|
||||
// const cdnJsonUrl = 'https://goood-space-assets.oss-cn-beijing.aliyuncs.com/public/models/hand-knn-model.json';
|
||||
// await loadKNNModelData(null, cdnJsonUrl);
|
||||
// updateGlobalStatus('CDN 手势识别模型加载成功!');
|
||||
// isModelLoaded = true;
|
||||
// importModelBtn.disabled = true;
|
||||
// startStopBtn.disabled = false;
|
||||
// } catch (cdnError) {
|
||||
// console.warn('CDN 模型加载失败:', cdnError);
|
||||
// updateGlobalStatus('请手动导入模型文件');
|
||||
// importModelBtn.disabled = false;
|
||||
// startStopBtn.disabled = true;
|
||||
// }
|
||||
|
||||
} catch (error) {
|
||||
console.error('应用初始化失败:', error);
|
||||
|
8
game/钢琴/sounds/新建 文本文档.txt
Normal file
8
game/钢琴/sounds/新建 文本文档.txt
Normal file
@ -0,0 +1,8 @@
|
||||
<li><span class="note-id">ID 0:</span> 中央C (C2)</li>
|
||||
<li><span class="note-id">ID 1:</span> D2</li>
|
||||
<li><span class="note-id">ID 2:</span> E2</li>
|
||||
<li><span class="note-id">ID 3:</span> F2</li>
|
||||
<li><span class="note-id">ID 4:</span> G2</li>
|
||||
<li><span class="note-id">ID 5:</span> A2</li>
|
||||
<li><span class="note-id">ID 6:</span> B2</li>
|
||||
<li><span class="note-id">ID 7:</span> 高音C (C3)</li>
|
@ -89,7 +89,8 @@
|
||||
|
||||
// 定义需要被劫持的原始 URL 的域名模式
|
||||
const INTERCEPT_DOMAINS = [
|
||||
'https://tfhub.dev/',
|
||||
// 'https://tfhub.dev/',
|
||||
'https://tfhub.dev/google/tfjs-model/movenet/singlepose/lightning/4/',
|
||||
// 如果实际的最终模型文件仍然解析到 storage.googleapis.com,也需要包含
|
||||
// 例如:'https://storage.googleapis.com/tfjs-models/'
|
||||
// 或者你观察到的实际的最终 Google Storage 域名
|
||||
@ -111,8 +112,8 @@
|
||||
for (const domain of INTERCEPT_DOMAINS) {
|
||||
if (url.startsWith(domain)) {
|
||||
// 尝试从 URL 中提取文件名 (不包含查询参数)
|
||||
// 匹配 model.json 或 group1-shardXofY.bin
|
||||
const fileNameMatch = url.match(/(model\.json|group1-shard\dof\d\.bin)/);
|
||||
// 匹配 model.json 或 group1-shardXof2.bin
|
||||
const fileNameMatch = url.match(/(model\.json|group1-shard\dof2\.bin)/);
|
||||
if (fileNameMatch) {
|
||||
const fileName = fileNameMatch[0]; // 获取匹配到的文件名
|
||||
newUrl = MIRROR_SPECIFIC_FILENAME_PREFIX + fileName; // 拼接新的镜像 URL
|
||||
@ -192,6 +193,7 @@
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<!-- 引入所有依赖库 -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@4.20.0/dist/tf.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/pose-detection@2.1.3/dist/pose-detection.min.js"></script>
|
||||
|
@ -16,9 +16,8 @@
|
||||
// 定义需要被劫持的原始 URL 的域名模式
|
||||
// 我们观察到最终请求来自 storage.googleapis.com
|
||||
const INTERCEPT_DOMAINS = [
|
||||
'https://storage.googleapis.com/tfjs-models/', // tfjs 官方模型常用的 CDN
|
||||
'https://storage.googleapis.com/', // 更宽泛的匹配 Google Storage
|
||||
'https://tfhub.dev/', // 如果 MobileNet 也会通过 tfhub.dev 间接加载
|
||||
// 'https://tfhub.dev/', // 如果 MobileNet 也会通过 tfhub.dev 间接加载
|
||||
'https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/classification/2/',
|
||||
];
|
||||
|
||||
// 备份原始的 fetch 函数
|
||||
@ -38,7 +37,7 @@
|
||||
if (url.startsWith(domain)) {
|
||||
// 尝试从 URL 中提取文件名 (不包含查询参数)
|
||||
// 匹配 model.json 或 group1-shardXofY.bin
|
||||
const fileNameMatch = url.match(/(model\.json|group1-shard\dof\d\.bin)/);
|
||||
const fileNameMatch = url.match(/(model\.json|group1-shard\dof4\.bin)/);
|
||||
if (fileNameMatch) {
|
||||
const fileName = fileNameMatch[0]; // 获取匹配到的文件名
|
||||
newUrl = MOBILENET_MIRROR_BASE_URL + fileName; // 拼接新的镜像 URL
|
||||
@ -128,6 +127,8 @@
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/mobilenet@latest"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/knn-classifier@latest"></script>
|
||||
|
@ -183,6 +183,7 @@
|
||||
</div>
|
||||
<!-- !!!!!! 核心劫持代码:确保在任何 TF.js 库之前加载 !!!!!! -->
|
||||
<!-- 如果你有其他模型的劫持代码,请确保它们都先于 TF.js 库 -->
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
// 定义你的镜像服务器的公共前缀,用于存放 Speech Commands 模型文件
|
||||
@ -192,10 +193,8 @@
|
||||
// 定义需要被劫持的原始 URL 的域名模式
|
||||
// 明确指出是 tfjs-models 下的 speech-commands 模型
|
||||
const INTERCEPT_DOMAINS = [
|
||||
'https://storage.googleapis.com/tfjs-models/tfjs/speech-commands/',
|
||||
// 如果实际请求路径更短,也可以包含更宽泛的匹配
|
||||
// 'https://storage.googleapis.com/tfjs-models/',
|
||||
// 'https://storage.googleapis.com/',
|
||||
// 'https://storage.googleapis.com/tfjs-models/tfjs/speech-commands/',
|
||||
'https://storage.googleapis.com/tfjs-models/tfjs/speech-commands/v0.5/browser_fft/18w/',
|
||||
];
|
||||
|
||||
// 备份原始的 fetch 函数
|
||||
@ -215,7 +214,7 @@
|
||||
if (url.startsWith(domain)) {
|
||||
// 尝试从 URL 中提取文件名 (不包含查询参数)
|
||||
// 匹配 metadata.json, model.json, group1-shardXofY (注意这里没有.bin后缀)
|
||||
const fileNameMatch = url.match(/(metadata\.json|model\.json|group1-shard\dof\d)/);
|
||||
const fileNameMatch = url.match(/(metadata\.json|model\.json|group1-shard\dof2)/);
|
||||
if (fileNameMatch) {
|
||||
const fileName = fileNameMatch[0]; // 获取匹配到的文件名
|
||||
newUrl = SPEECH_COMMANDS_MIRROR_BASE_URL + fileName; // 拼接新的镜像 URL
|
||||
@ -299,6 +298,7 @@
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest/dist/tf.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/speech-commands@latest/dist/speech-commands.min.js"></script>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user