| 123456789101112131415161718192021222324252627282930313233 |
- # 从 GitHub 下载 OnnxOCR 到当前 python 目录
- # 用法:在 PowerShell 中执行 .\download-onnxocr.ps1
- $ErrorActionPreference = "Stop"
- $pythonDir = $PSScriptRoot
- $zipPath = Join-Path $pythonDir "onnxocr-main.zip"
- $extractPath = Join-Path $pythonDir "onnxocr-temp"
- $targetPath = Join-Path $pythonDir "OnnxOCR"
- Write-Host "Downloading OnnxOCR from GitHub..."
- try {
- Invoke-WebRequest -Uri "https://github.com/jingsongliujing/onnxocr/archive/refs/heads/main.zip" `
- -OutFile $zipPath -UseBasicParsing
- } catch {
- Write-Host "Download failed. Try git clone:"
- Write-Host " cd $pythonDir"
- Write-Host " git clone --depth 1 https://github.com/jingsongliujing/onnxocr.git OnnxOCR"
- exit 1
- }
- Write-Host "Extracting..."
- if (Test-Path $extractPath) { Remove-Item -Recurse -Force $extractPath }
- Expand-Archive -Path $zipPath -DestinationPath $extractPath -Force
- $innerFolder = Get-ChildItem $extractPath -Directory | Select-Object -First 1
- if ($innerFolder) {
- if (Test-Path $targetPath) { Remove-Item -Recurse -Force $targetPath }
- Move-Item -Path $innerFolder.FullName -Destination $targetPath
- }
- Remove-Item -Recurse -Force $extractPath -ErrorAction SilentlyContinue
- Remove-Item -Force $zipPath -ErrorAction SilentlyContinue
- Write-Host "Done. OnnxOCR is at: $targetPath"
|