假如你是一个高级开发工程师,参考上面的显示提示框,在下面的代码上加个需求 startLoop 函数中弹出两次提示词 1 ,并且弹出遮罩层 停止音乐,输入对后,停1秒后马上弹出提示词2 , 输入对后 继续显示一批图片和播放音乐。你提示的信息和输入的词最好放在prompts 中 ,好维护。const prompts = [ { mainText: ‘测试1’, parts: [ { text: ‘本套课程价值上千,是否质量’, styles: ‘color: white; font-size: 24px;’ }, { text: ‘测试1’, styles: ‘font-weight: bold; color: red; font-size: 28px;’ } ] }, { mainText: ‘测试2’, parts: [ { text: ‘本套课程价值上千,是否愿意’, styles: ‘color: white; font-size: 24px;’ }, // 添加更多时间点的提示信息 ] }, ];

请在下面代码的基础上 改,不要删除其他功能 【 你添加了 let stageCount = 1; // 初始阶段为1 let shuffledImages = []; // 用于存储随机排序的图片数组 let shuffledVideos = []; // 用于存储随机排序的视频数组

要 函数按照要求在奇数阶段显示shuffledImages的随机图片,每张图片显示 200 毫秒,然后切换到下一张,这种状态持续 2 秒钟。在偶数阶段,它会显示shuffledVideos中的随机视频,每个视频显示 8 秒钟。 同样你模仿它创建1个循环,每隔2秒 随机选择一个视频显示 ,然后随机取10张图片 每图显示300毫秒。显示所有图后 再次循环。如下 使用一个计时器 timer 在每隔 200 毫秒 来显示图片, 直到显示完所有的图片。 在第一个 setTimeout 函数中,等待 2 秒后,清除了之前的计时器 timer。 随机选择一个视频并显示,然后等待 8 秒。 在第二个 setTimeout 函数中,再次使用一个计时器 timer 每隔 200 毫秒 ,直到显示完所有的图片。 最后,在第三个 setTimeout 函数中,等待 2 秒后,清除了计时器 timer,将 currentIndex 重置为 0,然后再次调用 startLoop() 函数,从头开始循环。 现在我的代码有点问题? 现在get_images.php?category=bianzhuang返回的json是 [ “24yhzb_out1.jpeg”, “show20dout.mp4”, “testabc.png”, “test.jpg”, …. ] 图片显示阶段1 【取值随机图片10个 ,每个图只显示200毫秒, 也就是2秒内快速显示10张图片 。】 视频显示阶段2 随机取1个mp4视频,直到播放完。 图片显示阶段3 【取值随机图片10个 ,每个图只显示200毫秒, 也就是2秒内快速显示10张图片 。】 阶段1的随机图片隔200毫秒显示,持续2秒【也就是这2秒内快速显示10张图片】。 阶段2的随机1个mp4视频 显示6秒,如果没有没有mp4视频则显示随机图片3秒 。 阶段3随机图片隔200毫秒显示,持续2秒。【也就是这2秒内快速显示10张图片】。 阶段4随机1个mp4视频 显示6秒,如果没有没有mp4视频则显示随机图片3秒 。 阶段5 阶段6 … 这样循环下去 总持续300秒 。

忘记之前的记录,请仔细看下面的代码和需求, 在这行 【 }, 2000); //阶段3 10张图,每个图只显示200毫秒,持续2秒 】的后面我想加个需求 从videos取1个mp4视频 播放,直到播放完后 接着阶段1 。

忘记之前的。仔细看下面代码 ,首先快速显示10张图片的阶段, 为什么每个图片没有显示300毫秒? 那个1张图先3秒是ok的,视频播放暂停音乐。视频播放完,继续显示10个图片 ,音乐自动开启也ok。 怎么改下 显示10张图片的阶段, 每个图片显示300毫秒 【 function startLoop() { // 首先快速显示10张图片,每张300毫秒 for (let i = 0; i < 10; i++) { showImage(currentIndex, 300); currentIndex++; } setTimeout(() => { // 显示1张图片3秒 showImage(currentIndex, 3000); setTimeout(() => { // 再次快速显示10张图片,每张300毫秒
for (let i = 0; i < 10; i++) { showImage(currentIndex, 300); currentIndex++;
} setTimeout(() => { videos = shuffleArray(videos); // 开始视频阶段 startVideoPhase(); }, 3000); }, 3000);
}, 3000);
// 随机重新排列图像数组 images = shuffleArray(images); } // 在 shuffleArray 函数中添加洗牌功能 function shuffleArray(array) { const shuffledArray = array.slice(); // 创建数组的副本 for (let i = shuffledArray.length - 1; i > 0; i–) { const j = Math.floor(Math.random() * (i + 1)); [shuffledArray[i], shuffledArray[j]] = [shuffledArray[j], shuffledArray[i]]; } return shuffledArray; } function startVideoPhase() { // 暂停音乐 audioPlayer.pause(); // 随机排列视频数组 videos = shuffleArray(videos); // 显示视频 const videoContainer = document.createElement(‘div’); videoContainer.style.display = ‘flex’; videoContainer.style.justifyContent = ‘center’; videoContainer.style.alignItems = ‘center’; videoContainer.style.width = ‘100%’; videoContainer.style.height = ‘100vh’; const videoElement = document.createElement(‘video’); const videoSrc = /life/static/${videos[Math.floor(currentIndex / 4)]}; videoElement.src = videoSrc; videoElement.controls = true; // 监听视频加载完毕事件 videoElement.addEventListener(‘canplaythrough’, function() { // 播放视频 videoElement.play(); }); videoElement.loop = false; videoElement.style.maxWidth = ‘90%’; videoContainer.appendChild(videoElement); imageContainer.innerHTML = ‘’; imageContainer.appendChild(videoContainer); // 监听视频播放结束事件 videoElement.addEventListener(“ended”, () => { // 检查视频是否播放到最后一帧 if (videoElement.currentTime === videoElement.duration) { currentIndex++; // 递增索引,以选择下一个视频 // 视频播放结束后,等待一段时间再继续阶段1(显示图片) setTimeout(() => { currentIndex = 0; // 重置索引为0 // 继续音乐播放 playMusic(); // 开始新的循环阶段 startLoop(); }, 100); // 9秒后继续阶段1 } }); } // 调用 startLoop 函数开始轮播 startLoop(); // 播放音乐函数 let audioPlayer; function playMusic() { const audioFile = ‘static/5a-Titanium-(Originally-Performed-By-David-Guetta-&-Sia)-[Karaoke-Version]-Titanium-I-Am-Titanium.mp3’; // 替换成你的音乐文件路径 audioPlayer = new Audio(audioFile); audioPlayer.play(); audioPlayer.addEventListener(’ended’, function() { this.currentTime = 0; this.play(); }); } // 调用播放音乐函数 playMusic();

下面代码基本ok ,但有2个问题。 1有些图片很高。则超出浏览器,导致无法全部看到图片。需要下划才可看到下面部分。 2 有些图片很小我不希望显示 小于65像素的不要显示出来。 怎么解决?

下面代码基本ok ,但有2个问题。 弹出提示框后音乐不能暂停, 输入正确后 音乐开启播放。 弹出提示框后图片还在动。没有静止。要静止。

下面代码基本ok ,但有2个问题。 假如 有 mainText: ‘测试1’, mainText: ‘测试2’, showPrompt中的 startLoop() 走到mainText: ‘测试2’, 图片就静止了。 因为后面没有 mainText了 showPrompt不动了 ,没有了 图片轮播。但 // 设置停止循环的定时器 setTimeout(() => { stopLoop(); }, 300000); 是5分钟 怎么解决

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 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
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
function showPrompt() {
  const prompt = prompts[currentPromptIndex];

  // 创建遮罩层
  const overlay = document.createElement('div');
  overlay.id = 'promptOverlay';
  overlay.style.position = 'fixed';
  overlay.style.top = '0';
  overlay.style.left = '0';
  overlay.style.width = '100%';
  overlay.style.height = '100%';
  overlay.style.backgroundColor = 'rgba(0, 0, 0, 0.9)';
  overlay.style.zIndex = '9998';

  // 创建提示框容器
  const promptContainer = document.createElement('div');
  promptContainer.id = 'promptContainer';
  promptContainer.style.position = 'absolute';
  promptContainer.style.top = '50%';
  promptContainer.style.left = '50%';
  promptContainer.style.transform = 'translate(-50%, -50%)';
  promptContainer.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
  promptContainer.style.padding = '20px'; // 调整内边距
  promptContainer.style.color = '#fff';
  promptContainer.style.textAlign = 'center';
  promptContainer.style.fontSize = '36px';
  promptContainer.style.whiteSpace = 'pre-wrap'; // 保留换行并根据容器宽度换行
  promptContainer.style.zIndex = '9999';

  // 添加提示文字
  const promptTextElement = document.createElement('div');
  prompt.parts.forEach(part => {
    const partElement = document.createElement('p');
    partElement.innerHTML = part.text;
    partElement.style.cssText = part.styles;
    promptTextElement.appendChild(partElement);
  });

  // 添加输入框
  const inputElement = document.createElement('input');
  inputElement.type = 'text';
  inputElement.id = 'promptInput';
  inputElement.style.marginTop = '10px';
  inputElement.style.display = 'none'; // 初始状态隐藏输入框

  // 添加确认按钮
  const submitButton = document.createElement('button');
  submitButton.innerText = '确认';
  submitButton.id = 'submitButton';
  submitButton.classList.add('button-style'); // 添加按钮的类名以应用样式
  submitButton.style.display = 'none'; // 初始状态隐藏按钮

  // 添加到提示框容器
  promptContainer.appendChild(promptTextElement);
  promptContainer.appendChild(inputElement);
  promptContainer.appendChild(submitButton);

  // 添加到遮罩层和页面中
  overlay.appendChild(promptContainer);
  document.body.appendChild(overlay);

  // 使用定时器,在展示提示框后等待6秒后显示输入框和按钮
  setTimeout(function () {
    inputElement.style.display = 'block'; // 显示输入框
    submitButton.style.display = 'block'; // 显示确认按钮
  }, 6000); // 等待6秒后显示

	 // 停止轮播
	 clearInterval(timer);
	  isPaused = true;
	  // 暂停音乐
	  audioPlayer.pause();

  // 监听确认按钮的点击事件
  submitButton.addEventListener('click', function () {
    const userInput = inputElement.value.trim();
    const expectedText = prompts[currentPromptIndex].mainText;

    if (userInput === expectedText) {
    // 继续轮播
  startLoop();
  // 恢复音乐
  audioPlayer.play();

      document.body.removeChild(overlay); // 移除遮罩层
      currentPromptIndex++;
    
      if (currentPromptIndex < prompts.length) {
        setTimeout(function () {
          player.play();
        }, 1000); // 等待1秒后继续播放音乐
      } else {
        player.on('timeupdate', checkPrompt);
      }
    } else {
      alert('提示文字不正确,请重新输入。');
    }
  });
}
第一步 第三步我已经做了,第二部不是很懂。具体改startLoop函数哪里 
然后在startLoop函数的setTimeout回调中,判断isPromptShown状态:
 setTimeout(() => {

  if (isPromptShown) {
    // 提示框显示中,不做操作
  } else {
    // 没有提示框,继续显示图片
    showImage(currentIndex); 
  }

}, interval);
startLoop代码如下
 function startLoop() {
  let timer;
  let currentIndex = 0;
  let isPaused = false;
  let interval = 255; // 初始时间间隔为 255 毫秒

  function continueLoop() {
    timer = setInterval(() => {
      if (!isPaused) {
        showImage(currentIndex);
        currentIndex = (currentIndex + 1) % images.length;
      }
   }, interval); // 可以写 interval  或写死数字255
  }
  // 快速显示一批图片(每张图片显示255毫秒)
  continueLoop();
  setTimeout(() => {
    clearInterval(timer);
    // 显示一张图片3秒
    showImage(currentIndex);
    isPaused = true; // 暂停轮播
    setTimeout(() => {
      isPaused = false; // 恢复轮播
      currentIndex = 0;
      // 递减时间间隔,然后再次快速显示一批图片
      interval -= 55; // 递减时间间隔
      continueLoop();
      setTimeout(() => {
        clearInterval(timer);
    ....
        // 等待2秒后重新排列图像数组。也就是在之前的continueLoop轮播图片是不变的。 
        images = shuffleArray(images);
		// 弹出第一个输入提示框,等待用户输入正确提示文字1
         showPrompt();
      }, 3000); //  快速显示一批图片 持续3秒
    }, 3000); // 显示一张图片3秒
  }, 3000); //  快速显示一批图片 持续3秒
    ......
}

setTimeout(() => {
  stopLoop();
}, 300000); 



function startLoop() {

  let timer;
  let currentIndex = 0;
  let isPaused = false;
  let interval = 255;

  function continueLoop() {
    // 省略
  }

  continueLoop();

  setTimeout(() => {

    if (isPromptShown) {
      // 提示框显示中,不做操作
    } else {
      clearInterval(timer);
    
      showImage(currentIndex);
      isPaused = true; 
    
      setTimeout(() => {
        isPaused = false;
        currentIndex = 0;
        interval -= 55;
        continueLoop();
    
        setTimeout(() => {
          
          if (isPromptShown) {
            // 提示框显示中,不做操作
          } else {
            // 显示图片代码
          }
    
        }, 3000);
    
      }, 3000);
    }

  }, 3000);

}	  
  ./jm.php   ../jm.php

./get_images.php?category=fetishism ../get_images.php?category=fetishism

有问题, 需求1 这行 【 // 调用 startLoop 函数开始轮播 startLoop();】 怎么保证图片和视频每次都是随机的。现在后面播放的一直是重复的视频。重复的图片 需求2 看有些图片直接显示白色的就过了。不知是没有下载好,还是怎么回事,怎么保证图片下载好后 显示300毫秒。

有问题 我看了 第一个视频 第二个视频是随机的,第三个视频和第二个一样。包括后面图片 一直显示和第二次一样的图片 。开头是随机的。为什么 怎么改 。 代码如下:

1
2
3
4
/usr/share/nginx/html/dutu/vipspouse/健身-瑜伽-保健-美体-美食
/usr/share/nginx/html/dutu/vipspouse/Download/手机
/usr/share/nginx/html/dutu/vipspouse/Download/电脑照片
/usr/share/nginx/html/dutu/vipspouse/Download/7701

下面代码是 取/usr/share/nginx/html/dutu/life/static 的图片和mp4。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 <?php
$baseDirectory = 'static';
$subDirectories = array_diff(scandir($baseDirectory), array('..', '.'));

$category = $_GET['category'];

if (in_array($category, $subDirectories)) {
   $directory = $baseDirectory . '/' . $category;

   $images = array();
   
   // 扫描目录并获取所有图片文件
   if (is_dir($directory)) {
       $files = scandir($directory);
       foreach ($files as $file) {
           $fileInfo = pathinfo($file);
           if (isset($fileInfo['extension']) && in_array($fileInfo['extension'], array('jpg', 'png','jpeg','mp4'))) {
           //if (isset($fileInfo['extension']) && in_array($fileInfo['extension'], array('jpeg','mp4'))) {
               $images[] = $file;
           }
       }
   }
   
   header('Content-Type: application/json');
   echo json_encode($images);
} else {
   echo 'Invalid category';
}
?>

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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
@echo off

if not defined PYTHON (set PYTHON=python)
if not defined VENV_DIR (set "VENV_DIR=%~dp0%venv")

mkdir tmp 2>NUL

%PYTHON% -c "" >tmp/stdout.txt 2>tmp/stderr.txt
if %ERRORLEVEL% == 0 goto :check_pip
echo Couldn't launch python
goto :show_stdout_stderr

:check_pip
%PYTHON% -mpip --help >tmp/stdout.txt 2>tmp/stderr.txt
if %ERRORLEVEL% == 0 goto :start_venv
if "%PIP_INSTALLER_LOCATION%" == "" goto :show_stdout_stderr
%PYTHON% "%PIP_INSTALLER_LOCATION%" >tmp/stdout.txt 2>tmp/stderr.txt
if %ERRORLEVEL% == 0 goto :start_venv
echo Couldn't install pip
goto :show_stdout_stderr

:start_venv
if ["%VENV_DIR%"] == ["-"] goto :skip_venv
if ["%SKIP_VENV%"] == ["1"] goto :skip_venv

dir "%VENV_DIR%\Scripts\Python.exe" >tmp/stdout.txt 2>tmp/stderr.txt
if %ERRORLEVEL% == 0 goto :activate_venv

for /f "delims=" %%i in ('CALL %PYTHON% -c "import sys; print(sys.executable)"') do set PYTHON_FULLNAME=%%i
echo Creating venv in directory %VENV_DIR% using python %PYTHON_FULLNAME%
%PYTHON_FULLNAME% -m venv "%VENV_DIR%" >tmp/stdout.txt 2>tmp/stderr.txt
if %ERRORLEVEL% == 0 goto :activate_venv
echo Unable to create venv in directory "%VENV_DIR%"
goto :show_stdout_stderr

:activate_venv
set PYTHON="%VENV_DIR%\Scripts\Python.exe"
echo venv %PYTHON%
python\python.exe  venv\Lib\site-packages\flatbuffers\encode.py "D:\Software\AI\roop\resource\roop\test\梓涵大大\23.jpg" -o 23.pt 
pause

报错:USERNAME=bl USERPROFILE=C:\Users\bl WINDIR=C:\Windows TERM=cygwin HOME=/c/Users/bl 系统找不到指定的路径。 请按任意键继续. . . 当前目录下 python\python.exe 是有的。 当前目录下 venv\Lib\site-packages\flatbuffers\encode.py也是有的。 请问问题是哪里?

python “venv\Lib\site-packages\flatbuffers\encode.py” “D:\Software\AI\roop\resource\roop\test\23.jpg” -o “D:\Software\AI\roop\resource\roop\test\23.pt”

1
2

这里面那个是开启python环境的 【@echo off

if not defined PYTHON (set PYTHON=python) if not defined VENV_DIR (set “VENV_DIR=%~dp0%venv”)

set SD_WEBUI_RESTART=tmp/restart set ERROR_REPORTING=FALSE

mkdir tmp 2>NUL

%PYTHON% -c "" >tmp/stdout.txt 2>tmp/stderr.txt if %ERRORLEVEL% == 0 goto :check_pip echo Couldn’t launch python goto :show_stdout_stderr

:check_pip %PYTHON% -mpip –help >tmp/stdout.txt 2>tmp/stderr.txt if %ERRORLEVEL% == 0 goto :start_venv if “%PIP_INSTALLER_LOCATION%” == "" goto :show_stdout_stderr %PYTHON% “%PIP_INSTALLER_LOCATION%” >tmp/stdout.txt 2>tmp/stderr.txt if %ERRORLEVEL% == 0 goto :start_venv echo Couldn’t install pip goto :show_stdout_stderr

:start_venv if ["%VENV_DIR%"] == ["-"] goto :skip_venv if ["%SKIP_VENV%"] == [“1”] goto :skip_venv

dir “%VENV_DIR%\Scripts\Python.exe” >tmp/stdout.txt 2>tmp/stderr.txt if %ERRORLEVEL% == 0 goto :activate_venv

for /f “delims=” %%i in (‘CALL %PYTHON% -c “import sys; print(sys.executable)”’) do set PYTHON_FULLNAME="%%i" echo Creating venv in directory %VENV_DIR% using python %PYTHON_FULLNAME% %PYTHON_FULLNAME% -m venv “%VENV_DIR%” >tmp/stdout.txt 2>tmp/stderr.txt if %ERRORLEVEL% == 0 goto :activate_venv echo Unable to create venv in directory “%VENV_DIR%” goto :show_stdout_stderr

:activate_venv set PYTHON="%VENV_DIR%\Scripts\Python.exe" echo venv %PYTHON%

:skip_venv if [%ACCELERATE%] == [“True”] goto :accelerate goto :launch

:accelerate echo Checking for accelerate set ACCELERATE="%VENV_DIR%\Scripts\accelerate.exe" if EXIST %ACCELERATE% goto :accelerate_launch

:launch %PYTHON% launch.py %* if EXIST tmp/restart goto :skip_venv pause exit /b

:accelerate_launch echo Accelerating %ACCELERATE% launch –num_cpu_threads_per_process=6 launch.py if EXIST tmp/restart goto :skip_venv pause exit /b

:show_stdout_stderr

echo. echo exit code: %errorlevel%

for /f %%i in (“tmp\stdout.txt”) do set size=%%~zi if %size% equ 0 goto :show_stderr echo. echo stdout: type tmp\stdout.txt

:show_stderr for /f %%i in (“tmp\stderr.txt”) do set size=%%~zi if %size% equ 0 goto :show_stderr echo. echo stderr: type tmp\stderr.txt

:endofscript

echo. echo Launch unsuccessful. Exiting. pause

1
2
---
这个是启动环境 以及其它命令的bat代码。 

@echo off

if not defined PYTHON (set PYTHON=python) if not defined VENV_DIR (set “VENV_DIR=%~dp0%venv”)

set SD_WEBUI_RESTART=tmp/restart set ERROR_REPORTING=FALSE

mkdir tmp 2>NUL

%PYTHON% -c "" >tmp/stdout.txt 2>tmp/stderr.txt if %ERRORLEVEL% == 0 goto :check_pip echo Couldn’t launch python goto :show_stdout_stderr

:check_pip %PYTHON% -mpip –help >tmp/stdout.txt 2>tmp/stderr.txt if %ERRORLEVEL% == 0 goto :start_venv if “%PIP_INSTALLER_LOCATION%” == "" goto :show_stdout_stderr %PYTHON% “%PIP_INSTALLER_LOCATION%” >tmp/stdout.txt 2>tmp/stderr.txt if %ERRORLEVEL% == 0 goto :start_venv echo Couldn’t install pip goto :show_stdout_stderr

:start_venv if ["%VENV_DIR%"] == ["-"] goto :skip_venv if ["%SKIP_VENV%"] == [“1”] goto :skip_venv

dir “%VENV_DIR%\Scripts\Python.exe” >tmp/stdout.txt 2>tmp/stderr.txt if %ERRORLEVEL% == 0 goto :activate_venv

for /f “delims=” %%i in (‘CALL %PYTHON% -c “import sys; print(sys.executable)”’) do set PYTHON_FULLNAME="%%i" echo Creating venv in directory %VENV_DIR% using python %PYTHON_FULLNAME% %PYTHON_FULLNAME% -m venv “%VENV_DIR%” >tmp/stdout.txt 2>tmp/stderr.txt if %ERRORLEVEL% == 0 goto :activate_venv echo Unable to create venv in directory “%VENV_DIR%” goto :show_stdout_stderr

:activate_venv set PYTHON="%VENV_DIR%\Scripts\Python.exe" echo venv %PYTHON%

:skip_venv if [%ACCELERATE%] == [“True”] goto :accelerate goto :launch

:accelerate echo Checking for accelerate set ACCELERATE="%VENV_DIR%\Scripts\accelerate.exe" if EXIST %ACCELERATE% goto :accelerate_launch

:launch %PYTHON% launch.py %* if EXIST tmp/restart goto :skip_venv pause exit /b

:accelerate_launch echo Accelerating %ACCELERATE% launch –num_cpu_threads_per_process=6 launch.py if EXIST tmp/restart goto :skip_venv pause exit /b

:show_stdout_stderr

echo. echo exit code: %errorlevel%

for /f %%i in (“tmp\stdout.txt”) do set size=%%~zi if %size% equ 0 goto :show_stderr echo. echo stdout: type tmp\stdout.txt

:show_stderr for /f %%i in (“tmp\stderr.txt”) do set size=%%~zi if %size% equ 0 goto :show_stderr echo. echo stderr: type tmp\stderr.txt

:endofscript

echo. echo Launch unsuccessful. Exiting. pause

我只要启动python环境的部分 。请选出启动python环境部分的代码

在当前目录运行 比如 D:\Software\AI\miaoshouai-sd-webui-v230222full目录下 运行 python\python.exe venv\Lib\site-packages\flatbuffers\encode.py “D:\Software\AI\roop\resource\roop\test\梓涵大大\23.jpg” -o 23.pt 这个命令 。因为我单独运行 python\python.exe venv\Lib\site-packages\flatbuffers\encode.py “D:\Software\AI\roop\resource\roop\test\梓涵大大\23.jpg” -o 23.pt 运行不了


新需求: /usr/share/nginx/html/dutu/life/get_vipspouse_img_video.php 实现 扫描下面目录下 包括其子目录下的图片(‘jpg’, ‘png’,‘jpeg)和视频(mp4 avi|mkv|mov|flv) 目录: /usr/share/nginx/html/dutu/vipspouse/健身-瑜伽-保健-美体-美食 /usr/share/nginx/html/dutu/vipspouse/Download/手机 /usr/share/nginx/html/dutu/vipspouse/Download/电脑照片 /usr/share/nginx/html/dutu/vipspouse/Download/7701

格式为json [ “vipspouse/Download/手机/1.jpeg”, “vipspouse/Download/手机/2.mp4”, “vipspouse/Download/手机/3.png”, “vipspouse/Download/手机/4.jpg”, …. ] 注意json中的路径和html的路径要匹配,确保/usr/share/nginx/html/dutu/life/tuvip.html 也就是url http://192.168.11.168:8900/life/tuvip.html 能显示图片、 视频。 下面 能直接显示图片

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
......
   fetch("get_vipspouse_img_video.php?category=手机")
        .then((response) => response.json())
        .then((data) => {
          //images = data;
		  // 筛选并保留图片文件名
          images = data.filter((item) => item.match(/\.(jpeg|jpg|png|gif|bmp)$/i));
		  // 筛选并保留视频文件名
          videos = data.filter((item) => item.match(/\.(mp4|avi|mkv|mov|flv)$/i));
          // 将图片数组进行随机排序
          images = shuffleArray(images);
		  // 将视频数组进行随机排序
		  videos = shuffleArray(videos);
		  ....
 videoElement.src = `../${videos[Math.floor(currentIndex / 4)]}`;
 const imageUrl = `../${imageName}`;
 ......

?category=健身-瑜伽-保健-美体-美食 优化下 1 get_vipspouse_img_video.php?category=Download/手机 只取/usr/share/nginx/html/dutu/vipspouse/Download/手机 扫描该目录下 包括其子目录下的图片(‘jpg’, ‘png’,‘jpeg)和视频(mp4 avi|mkv|mov|flv) 2 json 格式为 ,注意路径不是绝对的 [ “vipspouse/Download/手机/1.jpeg”, “vipspouse/Download/手机/b/2.mp4”, “vipspouse/Download/手机/c/1/.png”, “vipspouse/Download/手机/d/1/2/4.jpg”, …. ] 因为/usr/share/nginx/html/dutu/life/tuvip.html 也就是url http://192.168.11.168:8900/life/tuvip.html 能显示图片、 视频。 下面 能直接显示图片 videoElement.src = ../vipspouse/${videos[Math.floor(currentIndex / 4)]}; const imageUrl = ../vipspouse/${imageName};

http://192.168.11.168:8900/life/get_vipspouse_img_video.php?category=%E5%81%A5%E8%BA%AB-%E7%91%9C%E4%BC%BD-%E4%BF%9D%E5%81%A5-%E7%BE%8E%E4%BD%93-%E7%BE%8E%E9%A3%9F 能取出图片和视频了但json中你是绝对路径 我要相对路径 比如 [ “vipspouse/健身-瑜伽-保健-美体-美食/1.jpeg”, “vipspouse/健身-瑜伽-保健-美体-美食/b/2.mp4”, “vipspouse/健身-瑜伽-保健-美体-美食/c/1/.png”, “vipspouse/健身-瑜伽-保健-美体-美食/d/1/2/4.jpg”, …. ] 你取的是 “/dutu/vipspouse/健身-瑜伽-保健-美体-美食/test.png”,

现在json是 健身-瑜伽-保健-美体-美食/1.jpeg", 相对路径了 url http://192.168.11.168:8900/life/tuvip.html 能显示图片、 视频了。 videoElement.src = ../vipspouse/${videos[Math.floor(currentIndex / 4)]}; const imageUrl = ../vipspouse/${imageName}; 问题是 取值 http://192.168.11.168:8900/life/get_vipspouse_img_video.php?category=%E5%81%A5%E8%BA%AB-%E7%91%9C%E4%BC%BD-%E4%BF%9D%E5%81%A5-%E7%BE%8E%E4%BD%93-%E7%BE%8E%E9%A3%9F 要很久才能返回json。 需求1: http://192.168.11.168:8900/life/get_vipspouse_img_video.php 一次性取出 。如果目录变动要重新执行这个。手动 写入json文件夹 /usr/share/nginx/html/dutu/vipspouse/健身-瑜伽-保健-美体-美食 /usr/share/nginx/html/dutu/vipspouse/Download/手机 /usr/share/nginx/html/dutu/vipspouse/Download/电脑照片 /usr/share/nginx/html/dutu/vipspouse/Download/7701 目录下包括子目录下的的图片(‘jpg’, ‘png’,‘jpeg)和视频(mp4 avi|mkv|mov|flv)。写到get_vipspouse_img_video.json文件中 路径用相对的。

需求2 现在 get_vipspouse_img_video.json 有了值 [ “健身-瑜伽-保健-美体-美食/1.jpeg”, “Download/手机/b/2.mp4”, “Download/电脑照片/c/1/.png”, “Download/7701/d/1/2/4.jpg”, …. ]

比如url http://192.168.11.168:8900/life/tuvip.html 页面中 四个按钮 分别显示 健身-瑜伽-保健-美体-美食 手机 电脑照片 7701
我选择 健身-瑜伽-保健-美体-美食按钮 ,则自动取出 get_vipspouse_img_video.json中的 健身-瑜伽-保健-美体-美食 目录 的图片和视频 ,分别用来显示图片和播放视频

参考life/tuvip.html 整体代码 改下:

下面代码有个问题: 1 点暂停 能停止图片滚动状态 ,但会过几秒显示另外一种图片。 点继续 图片不能继续滚动显示,怎样改下点暂停。图片就停止滚动 显示当前图片。直到点继续。图片继续按之前那样滚动显示。

AbyssOrangeMix2_sfw.ckpt beautifulRealistic_v60.safetensors chilloutmix_NiPrunedFp32Fix.safetensors GuoFeng3.ckpt yesmix_v16Original.safetensors

下面代码图片轮播OK,但是get_images.php?category=bianzhuang返回的json中有些mp4视频,比如show20dout.mp4, http://test.com/life/static/bianzhuang/show20dout.mp4 是可以正常播放的。 在下面代码基础上,不要改原来的功能,怎么改下使 碰到随机的值是mp4时 则正常播放mp4.

还是一样的 。以显示图片和视频了,但是视频只显示200毫秒或3秒。(这是图片显示的逻辑)可能之前的逻辑不好。 我想 只要视频在 阶段 2 ,阶段4 … 等 显示视频。
function startLoop() 的逻辑是 阶段1的随机图片隔200毫秒显示,持续2秒。阶段2的随机1图片显示3秒 。阶段3随机图片隔200毫秒显示,持续2秒。阶段4的随机1图片显示3秒 。这样循环下去 总持续300秒 。 问题1 怎么得到get_images.php?category=bianzhuang返回的json的mp4和除了mp4的其它元素 。 问题2 只要视频在 阶段 2 ,阶段4 … 等 显示视频。如果没有视频 则随机显示1个图片 持续3秒。整个代码可以参考今天第一次提问给你的代码 现在get_images.php?category=bianzhuang返回的json是 [ “24yhzb_out1.jpeg”, “show20dout.mp4”, “testabc.png”, “test.jpg”, …. ] 你怎么保证, 奇数阶段显示的是全部是图片呢。有没有可能 夹杂一些视频。 在偶数阶段必须显示mp4视频。显示8秒钟 。 现在问题是奇数阶段没有显示够10张图。 问题1 视频播放时 按原分辨率的60%显示。 问题2 不要改动我之前的function startLoop() 的逻辑: 阶段1的随机图片隔200毫秒显示,持续2秒【也就是这2秒内快速显示10张图片】。 阶段2的随机1个mp4视频 显示6秒,如果没有没有mp4视频则显示随机图片3秒 。 阶段3随机图片隔200毫秒显示,持续2秒。【也就是这2秒内快速显示10张图片】。 阶段4随机1个mp4视频 显示6秒,如果没有没有mp4视频则显示随机图片3秒 。 阶段5 阶段6 … 这样循环下去 总持续300秒 。 请在原startLoop的基础上修改. 【所以我问你怎么得到get_images.php?category=bianzhuang返回的json的mp4和除了mp4的其它图片。这样你就会在2 4 6 8 10 等阶段随机显示视频。1 3 5 7 9等阶段显示图片】 下面是我原startLoop代码。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function startLoop() {
            timer = setInterval(() => {
              if (!isPaused) {
                showImage(currentIndex);
                currentIndex = (currentIndex + 1) % images.length;
              }
            }, 200);
            setTimeout(() => {
              clearInterval(timer);
              const randomIndex = Math.floor(Math.random() * images.length);
              showImage(randomIndex);
              setTimeout(() => {
                timer = setInterval(() => {
                  if (!isPaused) {
                    showImage(currentIndex);
                    currentIndex = (currentIndex + 1) % images.length;
                  }
                }, 200);
                setTimeout(() => {
                  clearInterval(timer);
                  currentIndex = 0;
                  startLoop();
                }, 2000);
              }, 3000);
            }, 2000);
          }
      setTimeout(() => {
        clearInterval(timer);
      }, 300000); 

python实现 对 V:\d_bak\Download\电脑照片目录下的所有jsonl文件类型,并且文件名不包含simplify ,的文件 进行处理 ,保留json中的imgInfo, 删除json中的numData 、textDebug、textBlockList下面的box 和score 。保留textBlockList下面的 text 。 处理后的内容 已utf-8格式保存到 原文件名_simplify.jsonl
比如 V:\d_bak\Download\电脑照片[转文字]_电脑照片.jsonl 很多json ,几百兆,我要删除一些没有用的json内容。 比如文件部分json示例

1
2
{"imgInfo": {"name": "5a 皮肤管理 形象管理.png", "path": "V:\\d_bak\\Download\\电脑照片\\5a 皮肤管理 形象管理.png", "size": [647, 1117]}, "textBlockList": [{"box": [[70, 38], [98, 38], [99, 333], [71, 333]], "score": 0.9246211051940918, "text": "南方医科大学珠江医院"}, {"box": [[109, 75], [137, 75], [137, 189], [109, 189]], "score": 0.8804203867912292, "text": "主任医师"}, {"box": [[109, 214], [137, 214], [137, 354], [109, 354]], "score": 0.996804416179657, "text": "张堂德教授"}, {"box": [[73, 705], [560, 705], [560, 751], [73, 751]], "score": 0.9965720772743225, "text": "异维A酸红霉素凝胶"}, {"box": [[224, 786], [388, 786], [388, 822], [224, 822]], "score": 0.926403820514679, "text": "建立耐受:"}, {"box": [[29, 823], [572, 824], [572, 857], [29, 856]], "score": 0.9352145791053772, "text": "第一个星期每晚涂药后一小时洗掉"}, {"box": [[83, 861], [548, 863], [548, 894], [83, 892]], "score": 0.9332819581031799, "text": "第二周涂药后第二天早上洗掉"}, {"box": [[14, 904], [299, 907], [299, 964], [14, 961]], "score": 0.91725093126297, "text": "皮肤比较黑"}, {"box": [[101, 975], [630, 975], [630, 1034], [101, 1034]], "score": 0.9575268626213074, "text": "可以用含维C烟酰胺"}, {"box": [[107, 1050], [501, 1053], [501, 1105], [107, 1103]], "score": 0.9172630310058594, "text": "熊果苷的护肤品"}], "numData": {"all": 11, "now": 8, "index": 7, "succ": 8, "err": 0, "exist": 8, "none": 0, "time": 10.492523908615112, "timeNow": 0.6320958137512207}, "textDebug": "[横排-单行] 原10块,合并后10块,耗时0.0s\n总耗时:0.6320958137512207s  置信度:0.9385359168052674\n"}
{"imgInfo": {"name": "5a -前列腺炎 运动.jpg", "path": "V:\\d_bak\\Download\\电脑照片\\5a -前列腺炎 运动.jpg", "size": [1223, 962]}, "textBlockList": [{"box": [[1024, 17], [1219, 20], [1219, 50], [1024, 47]], "score": 0.849174976348877, "text": "医疗科普仅供"}, {"box": [[602, 21], [673, 21], [673, 43], [602, 43]], "score": 0.7772318124771118, "text": "画中画 "}, {"box": [[72, 150], [146, 150], [146, 344], [72, 344]], "score": 0.9021999537944794, "text": "中国中医科学院张兆发"}, {"box": [[72, 325], [145, 325], [145, 557], [72, 557]], "score": 0.9519522488117218, "text": "广安门医院教授主任医师"}, {"box": [[258, 448], [984, 450], [984, 511], [258, 508]], "score": 0.9936737418174744, "text": "盆底肌肉锻炼的方法"}, {"box": [[253, 532], [1208, 532], [1208, 592], [253, 592]], "score": 0.9526086449623108, "text": "空腹时假憋尿9秒放松9秒"}, {"box": [[333, 616], [940, 620], [940, 683], [333, 680]], "score": 0.9192221760749817, "text": "每天做15一35次"}, {"box": [[793, 693], [1045, 693], [1045, 727], [793, 727]], "score": 0.9965136647224426, "text": "综合训练方法"}, {"box": [[8, 695], [215, 697], [215, 732], [8, 730]], "score": 0.9941229820251465, "text": "膀胱训练法"}, {"box": [[715, 735], [1126, 737], [1126, 767], [715, 765]], "score": 0.9722391963005066, "text": "进行盆底肌训练的同时"}, {"box": [[7, 740], [462, 740], [462, 774], [7, 774]], "score": 0.9586505889892578, "text": "每次在小便池前站立不动"}, {"box": [[718, 780], [1124, 780], [1124, 809], [718, 809]], "score": 0.8485678434371948, "text": "要收缩会阴及肛门肌肉"}, {"box": [[47, 782], [378, 785], [378, 819], [47, 816]], "score": 0.9377020597457886, "text": "慢慢收肾盆底肌肉"}, {"box": [[715, 822], [1175, 824], [1175, 854], [715, 853]], "score": 0.8542067408561707, "text": "5秒后放松连续做4一7次"}, {"box": [[50, 827], [422, 827], [422, 858], [50, 858]], "score": 0.9436616897583008, "text": "直到排尿紧迫感消失"}, {"box": [[719, 866], [1159, 866], [1159, 896], [719, 896]], "score": 0.9727795124053955, "text": "然后快速收缩后放松8秒"}, {"box": [[20, 869], [426, 869], [426, 898], [20, 898]], "score": 0.8568274974822998, "text": "使排尿推迟2一13分钟"}, {"box": [[712, 908], [1155, 908], [1155, 936], [712, 936]], "score": 0.9419711828231812, "text": "重复一个周期每天做4次"}], "numData": {"all": 11, "now": 9, "index": 8, "succ": 9, "err": 0, "exist": 9, "none": 0, "time": 11.383642196655273, "timeNow": 0.8911182880401611}, "textDebug": "[横排-单行] 原21块,合并后18块,耗时0.0009975433349609375s\n总耗时:0.8911182880401611s  置信度:0.9235170284907023\n"}

python实现 对 V:\d_bak\Download\电脑照片 目录下的所有jsonl文件类型而且文件名必须包括 simplify 的文件。 比如其中一个[转文字]_电脑照片1_simplify.jsonl文件,1百多兆,这文件是一些图片的json信息。包含标题 内容信息。 1 进行关键字查找 , 这个关键字是在V:\d_bak\Download\电脑照片.keyword文件中 一行一个关键字。
2 比如比如关键字"沙雕动画" ,只要图片的json信息中(imgInfo下的name textBlockList下所有的text)含有沙雕动画这个字符串,就得到这些图片json中的 imgInfo的path信息。 3 先判断目录V:\d_bak\Download\new下面是否包含关键字的目录。没有则新建。有则把 查找到的图片移动到V:\d_bak\Download\new\沙雕动画 。并记录日志 具体时间 原图片绝对路径 移动到 目标路径 到.picture_classification.log ,并在控制台输出是关键词在 哪个simplify.jsonl 有哪个图片 具体对应路径信息 4 对其它关键字进行同样操作 直到.keyword文件中所有的关键字完成。 最终每个含关键字的图片都会放在相应关键字的目录中 比如其中一个[转文字]_电脑照片1_simplify.jsonl文件部分内容

1
2
 {"imgInfo": {"name": "沙雕动画test1.png", "path": "V:\\d_bak\\Download\\电脑照片\\沙雕动画test1.png", "size": [1944, 1218]}, "textBlockList": [{"text": "8.3w"}, {"text": "但目前玩法"}, {"text": "8"}, {"text": "却只有少数人戈知道"}, {"text": "1800"}, {"text": "★"}, {"text": "3.2w"}, {"text": "@冷水短视频运营"}, {"text": "挑战30秒教会你一一如何创作沙雕动画视频1,助你做中视频轻松变现~#中视频伙伴计划#干货分享 #沙雕动画"}, {"text": "."}, {"text": "●连播●清屏 智能倍速 田"}, {"text": "¥00:06/00:52"}]}
{"imgInfo": {"name": "沙雕动画test2.png", "path": "V:\\d_bak\\Download\\电脑照片\\沙雕动画test2.png", "size": [1944, 1218]}, "textBlockList": [{"text": "8.3w"}, {"text": "但目前玩法"}, {"text": "8"}, {"text": "却只有少数人戈知道"}, {"text": "1800"}, {"text": "★"}, {"text": "3.2w"}, {"text": "@冷水短视频运营"}, {"text": "挑战30秒教会你一一如何创作沙雕动画视频2,助你做中视频轻松变现~#中视频伙伴计划#干货分享 #沙雕动画"}, {"text": "."}, {"text": "●连播●清屏 智能倍速 田"}, {"text": "¥00:06/00:52"}]}

python 用jieba实现 对 V:\d_bak\Download\电脑照片 目录下的所有jsonl文件类型而且文件名必须包括 simplify 的文件。同时进行词频top20处理 (注意是对所有包括 simplify 的jsonl文件同时进行词频top20处理) 比如其中一个[转文字]_电脑照片1_simplify.jsonl文件,1百多兆,这文件是一些图片的json信息。包含标题 内容信息(imgInfo下的name textBlockList下所有的text)。 [转文字]_电脑照片1_simplify.jsonl文件部分内容

1
2
  {"imgInfo": {"name": "沙雕动画test1.png", "path": "V:\\d_bak\\Download\\电脑照片\\沙雕动画test1.png", "size": [1944, 1218]}, "textBlockList": [{"text": "8.3w"}, {"text": "但目前玩法"}, {"text": "8"}, {"text": "却只有少数人戈知道"}, {"text": "1800"}, {"text": "★"}, {"text": "3.2w"}, {"text": "@冷水短视频运营"}, {"text": "挑战30秒教会你一一如何创作沙雕动画视频1,助你做中视频轻松变现~#中视频伙伴计划#干货分享 #沙雕动画"}, {"text": "."}, {"text": "●连播●清屏 智能倍速 田"}, {"text": "¥00:06/00:52"}]}
{"imgInfo": {"name": "沙雕动画test2.png", "path": "V:\\d_bak\\Download\\电脑照片\\沙雕动画test2.png", "size": [1944, 1218]}, "textBlockList": [{"text": "8.3w"}, {"text": "但目前玩法"}, {"text": "8"}, {"text": "却只有少数人戈知道"}, {"text": "1800"}, {"text": "★"}, {"text": "3.2w"}, {"text": "@冷水短视频运营"}, {"text": "挑战30秒教会你一一如何创作沙雕动画视频2,助你做中视频轻松变现~#中视频伙伴计划#干货分享 #沙雕动画"}, {"text": "."}, {"text": "●连播●清屏 智能倍速 田"}, {"text": "¥00:06/00:52"}]}

…..


假如你是一个高级开发工程师 python 用hanlp2.x实现 对 V:\d_bak\Download\电脑照片 目录下的所有jsonl文件类型而且文件名必须包括 simplify 的文件。同时进行词频top20处理 (注意是对所有包括 simplify 的jsonl文件同时进行词频top20处理) 比如其中一个[转文字]_电脑照片1_simplify.jsonl文件,1百多兆,这文件是一些图片的json信息。包含标题 内容信息(imgInfo下的name textBlockList下所有的text)。 请参考下面hanlp2.1分词代码。对图片的json信息。包含标题 内容信息(imgInfo下的name textBlockList下所有的text)循环给HanLP([’ xxxxx test json imgInfo下的name 或者textBlockList下所有的text]) 进行分词,然后词频top20处理。 hanlp2.1分词代码:

1
2
3
4
5
6
7
8
import hanlp
HanLP = hanlp.load(hanlp.pretrained.mtl.CLOSE_TOK_POS_NER_SRL_DEP_SDP_CON_ELECTRA_SMALL_ZH, devices=0) # 世界最大中文语料库
HanLP(['2021年HanLPv2.1为生产环境带来次世代最先进的多语种NLP技术。', '阿婆主来到北京立方庭参观自然语义科技公司。']) 

[转文字]_电脑照片1_simplify.jsonl文件部分内容
{"imgInfo": {"name": "沙雕动画test1.png", "path": "V:\\d_bak\\Download\\电脑照片\\沙雕动画test1.png", "size": [1944, 1218]}, "textBlockList": [{"text": "8.3w"}, {"text": "但目前玩法"}, {"text": "8"}, {"text": "却只有少数人戈知道"}, {"text": "1800"}, {"text": "★"}, {"text": "3.2w"}, {"text": "@冷水短视频运营"}, {"text": "挑战30秒教会你一一如何创作沙雕动画视频1,助你做中视频轻松变现~#中视频伙伴计划#干货分享 #沙雕动画"}, {"text": "."}, {"text": "●连播●清屏 智能倍速 田"}, {"text": "¥00:06/00:52"}]}
{"imgInfo": {"name": "沙雕动画test2.png", "path": "V:\\d_bak\\Download\\电脑照片\\沙雕动画test2.png", "size": [1944, 1218]}, "textBlockList": [{"text": "8.3w"}, {"text": "但目前玩法"}, {"text": "8"}, {"text": "却只有少数人戈知道"}, {"text": "1800"}, {"text": "★"}, {"text": "3.2w"}, {"text": "@冷水短视频运营"}, {"text": "挑战30秒教会你一一如何创作沙雕动画视频2,助你做中视频轻松变现~#中视频伙伴计划#干货分享 #沙雕动画"}, {"text": "."}, {"text": "●连播●清屏 智能倍速 田"}, {"text": "¥00:06/00:52"}]}
.....

假如你是一个高级开发工程师 python 用hanlp1.x实现 对 V:\d_bak\Download\电脑照片 目录下的所有jsonl文件类型而且文件名必须包括 simplify 的文件。同时进行词频top20处理 (注意是对所有包括 simplify 的jsonl文件同时进行词频top20处理) 比如其中一个[转文字]_电脑照片1_simplify.jsonl文件,10多兆,这文件是一些图片的json信息。包含标题 内容信息(imgInfo下的name textBlockList下所有的text)。一个图片一个json信息。 请参考上面hanlp1.x汉字处理代码(自动摘要 , 关键词提取 ,短语提取)。对文件中的每个图片的json信息。包含标题 内容信息(imgInfo下的name textBlockList下所有的text)循环给HanLP1.x ([’ xxxxx test json imgInfo下的name 或者textBlockList下所有的text]) 进行自动摘要 , 关键词提取 ,短语提取 。并把结果保存到 对应文件名变量.log中。和输出到控制台中。

[转文字]_电脑照片1_simplify.jsonl文件部分内容

1
2
3
4
{"imgInfo": {"name": "沙雕动画test1.png", "path": "V:\\d_bak\\Download\\电脑照片\\沙雕动画test1.png", "size": [1944, 1218]}, "textBlockList": [{"text": "8.3w"}, {"text": "但目前玩法"}, {"text": "8"}, {"text": "却只有少数人戈知道"}, {"text": "1800"}, {"text": "★"}, {"text": "3.2w"}, {"text": "@冷水短视频运营"}, {"text": "挑战30秒教会你一一如何创作沙雕动画视频1,助你做中视频轻松变现~#中视频伙伴计划#干货分享 #沙雕动画"}, {"text": "."}, {"text": "●连播●清屏 智能倍速 田"}, {"text": "¥00:06/00:52"}]}
{"imgInfo": {"name": "沙雕动画test2.png", "path": "V:\\d_bak\\Download\\电脑照片\\沙雕动画test2.png", "size": [1944, 1218]}, "textBlockList": [{"text": "8.3w"}, {"text": "但目前玩法"}, {"text": "8"}, {"text": "却只有少数人戈知道"}, {"text": "1800"}, {"text": "★"}, {"text": "3.2w"}, {"text": "@冷水短视频运营"}, {"text": "挑战30秒教会你一一如何创作沙雕动画视频2,助你做中视频轻松变现~#中视频伙伴计划#干货分享 #沙雕动画"}, {"text": "."}, {"text": "●连播●清屏 智能倍速 田"}, {"text": "¥00:06/00:52"}]}

.....

假如你一个高级开发工程师,下面hanlp1.x代码基本能跑通了,但需改进下下面代码: 1 打印文件 改为该图片的路径.。我看你没有取到imgInfo下的path吗 2 摘要信息 不包括 imgInfo下的name , 只从textBlockList下所有的text 获取摘要。但看日志还包含 imgInfo下的name信息。 3 关键词 只输出1个汉字或字母以上的 至少是2个汉字或2个字母 4 短语 只输出1个汉字或字母以上的 至少是2个汉字或2个字母 5 词频选top4 代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import os
import json
from collections import Counter
from pyhanlp import *
# 指定目录
folder = 'V:\\d_bak\\Download\\电脑照片'
# 用于保存结果的字典
results = {}
# 初始化HanLP
basedir = "D:/Software/Miniconda3/envs/py38/Lib/site-packages/pyhanlp/static"
#核心词典路径
#HanLP.Config.CoreDictionaryPath ="D:/Software/Miniconda3/envs/py38/Lib/site-packages/pyhanlp/static/data/dictionary/CoreNatureDictionary.txt" 
HanLP.Config.CoreDictionaryPath =os.path.join(basedir, "data/dictionary/CoreNatureDictionary.txt")
#元语法词典路径
HanLP.Config.BiGramDictionaryPath =os.path.join(basedir, "data/dictionary/CoreNatureDictionary.ngram.txt")
#停用词词典路径
HanLP.Config.CoreStopWordDictionaryPath=os.path.join(basedir, "data/dictionary/stopwords.txt")
#同义词词典路径
HanLP.Config.CoreSynonymDictionaryDictionaryPath=os.path.join(basedir, "data/dictionary/synonym/CoreSynonym.txt")
#人名词典路径
HanLP.Config.PersonDictionaryPath=os.path.join(basedir, "data/dictionary/person/nr.txt")
#人名词典转移矩阵路径
HanLP.Config.PersonDictionaryTrPath=os.path.join(basedir, "data/dictionary/person/nr.tr.txt")
#繁简词典根目录
HanLP.Config.tcDictionaryRoot=os.path.join(basedir, "data/dictionary/tc")
#自定义词典路径,用;隔开多个自定义词典,空格开头表示在同一个目录,使用“文件名 词性”形式则表示这个词典的词性默认是该词性。优先级递减。
# 另外data/dictionary/custom/CustomDictionary.txt是个高质量的词库,请不要删除。所有词典统一使用UTF-8编码。
# 多个自定义词典文件,使用分号分隔
custom_dict_files = [
    "D:/Software/Miniconda3/envs/py38/Lib/site-packages/pyhanlp/static/data/dictionary/custom/CustomDictionary.txt",
    "现代汉语补充词库.txt",
    "全国地名大全.txt ns",
    "人名词典.txt",
    "机构名词典.txt",
    "上海地名.txt ns",
    "D:/Software/Miniconda3/envs/py38/Lib/site-packages/pyhanlp/static/data/dictionary/person/nrf.txt nr"
]
# 将多个自定义词典文件路径分别添加到列表中
custom_dict_paths = [os.path.abspath(f) for f in custom_dict_files]
# 配置HanLP的自定义词典路径为一个字符串数组
HanLP.Config.CustomDictionaryPath = custom_dict_paths
# 遍历目录下的文件
for filename in os.listdir(folder):
    if 'simplify' in filename and filename.endswith('.jsonl'):
        with open(os.path.join(folder, filename), 'r', encoding='utf-8') as f:
            for line in f:
                data = json.loads(line)
                text_contents = [
                    data['imgInfo']['path'],  # 使用图片路径代替文件名
                    ' '.join([x['text'] for x in data['textBlockList']])
                ]
                text = ' '.join(text_contents)
                # 从textBlockList下所有的text获取摘要
                summary = ' '.join([x['text'] for x in data['textBlockList']])
                # 进行关键词提取
                keywords = HanLP.extractKeyword(text, 5)
                # 进行短语提取
                phrases = HanLP.extractPhrase(text, 5)
                # 进行词频统计,并选择前4个词
                word_count = Counter(text.split())
                top4_words = word_count.most_common(4)
                # 保存结果到对应文件名.log中
                log_filename = os.path.splitext(filename)[0] + '.log'
                log_filepath = os.path.join(folder, log_filename)
                with open(log_filepath, 'a', encoding='utf-8') as log_file:
                    log_file.write(f"摘要: {summary}\n")
                    log_file.write(f"关键词: {', '.join(keywords)}\n")
                    log_file.write(f"短语: {', '.join(phrases)}\n")
                    log_file.write(f"词频统计: {', '.join([f'{word}: {count}' for word, count in top4_words])}\n\n")
                # 保存结果到字典
                results[filename] = {
                    '摘要': summary,
                    '关键词': keywords,
                    '短语': phrases,
                    '词频统计': top4_words
                }
# 打印结果
for filename, data in results.items():
    print(f"图片路径: {data['imgInfo']['path']}")
    print(f"摘要: {data['摘要']}")
    print(f"关键词: {', '.join(data['关键词'])}")
    print(f"短语: {', '.join(data['短语'])}")
    print(f"词频统计: {', '.join([f'{word}: {count}' for word, count in data['词频统计']])}\n")


V:\work\actual_combat\crawp3\picture_classification\word.txt 每行的构成 :3列, 第一列是 单词然后紧跟着是: 然后是数字 打印每行第一列是纯英文的行 ,并且只输出这行的第一列信息。一行一个。 word.txt的部分内容格式是这样的

清屏: 16 Telecom: 16 迭代: 15 一群: 15 商机: 15 提炼: 15 感恩: 15 必读: 15 吸气: 15 PC: 15 三大: 15 ….


我已经安装了pip install hanlp[full] 请用hnlp实现下面代码同样的功能

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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
62
63
64
65
import os
import json
import jieba
from collections import Counter
import re

# 指定要处理的目录
directory_to_process = r'V:\d_bak\Download\电脑照片'

# 初始化词频统计器
word_counter = Counter()

# 读取停用词文件并构建停用词集合
stopwords_file = r'V:\work\actual_combat\crawp3\down_csdn_upload_markdown_to_wordpress_tag_auto\dic\stopwords.txt'
with open(stopwords_file, 'r', encoding='utf-8') as stopwords_txt:
    stop_words = set(stopwords_txt.read().splitlines())
    print(f"停用词加载成功:{stopwords_file}")
    # 加载自定义词典
    custom_dict_file = r'V:\work\actual_combat\crawp3\down_csdn_upload_markdown_to_wordpress_tag_auto\dic\新建文件夹\jiebafc\dict\dict.big.txt'
    jieba.load_userdict(custom_dict_file)
    print(f"自定义字典加载成功:{custom_dict_file}")

# 遍历目录下的所有文件
for root, dirs, files in os.walk(directory_to_process):
    for file in files:
        if file.endswith("_simplify.jsonl"):
            # 构造文件的完整路径
            file_path = os.path.join(root, file)

            # 打开 JSONL 文件并处理每一行
            with open(file_path, 'r', encoding='utf-8') as jsonl_file:
                for line in jsonl_file:
                    # 解析JSON行
                    json_data = json.loads(line)
    
                    # 提取文本信息(假设要处理的文本在"textBlockList"中)
                    text_block_list = json_data.get('textBlockList', [])
                    for item in text_block_list:
                        text = item.get('text', '')
                        
                        # 预处理文本:去除特殊字符和多余的空格
                        text = re.sub(r'[^\w\s]', '', text)
                        text = text.strip()
    
                        # 使用jieba分词
                        words = jieba.cut(text)
    
                        # 更新词频统计,排除停用词和不符合长度和数字条件的词语
                        word_counter.update([word for word in words if word and word not in stop_words and
                                             (len(word) >= 2 or (re.match(r'[a-zA-Z]{3,}', word) and len(word) >= 3)) and
                                             not re.match(r'\d+', word) and
                                             word.lower() not in stop_words])  # 添加这行来排除停用词

 # 获取Top 20的词语和词频
top_words = word_counter.most_common(9000)

# 打开文件以追加模式写入
output_file_path = 'V:/work/actual_combat/crawp3/picture_classification/word-hanlp.txt'
with open(output_file_path, 'w', encoding='utf-8') as output_file:
    # 遍历Top 20的词语和词频
    for word, freq in top_words:
        # 将结果写入文件
        output_file.write(f"{word}: {freq}\n")
        # 同时打印结果
        print(f"{word}: {freq}")

由于之前有很多md文件的文章分布在不同的分类目录下(在同一父级目录下),使用docsify作为网站编译解释框架。

docsify用起来很舒服,之前在github.io没有seo方面的需求,后续有了seo的需求后,docsify在seo方面还需要等下一个大版本,实在等不及,只能考虑将批量转换所有md文件,支持hugo的Front Matter、内联md、摘要等属性设置。

写这个python脚本只是为了帮助人,而不是完全做了我们人该做的,本地也没有文章机器学习的能力,有机会考虑使用机器学习实现文章分类、标签、关键字、标题的自动生成,当然最后还是需要人为的完善这些自动生成的信息。

4.7 和 4.7.1 wd扫描 存在问题的 REST API ,修改 WordPress 网站内容时会产生一个修改数据包,攻击者通过 REST API 的构造数据包内容,将 URL 进行简单修改就可以绕过账号验证直接查看网站内容。此外还可以在未经身份验证的情况下任意增删改查文章、页面及其他内容

nmap -v -A fuliba.net nmap -Pn www.tizinet.com

DE8EF4EF9E0DBEE2DB1307D66BBFC584F64DFF2A


ai expert ai专家

Daily laugh 每日爆笑

Fiction tweet 小说推文

animation 动漫

goal 目标

Set goals 设立目标

big 大

simplify 精简

keyword 关键字

Picture classification 图片分类

collision 碰撞

programming 编程

随机文章