2026-02-02
Python
00
bash
展开代码
#!/usr/bin/env python3 """ 断点续传文件到服务器 使用 paramiko 库实现 SFTP 断点续传 """ import os import sys import paramiko from tqdm import tqdm def get_remote_file_size(sftp, remote_path): """获取远程文件大小""" try: return sftp.stat(remote_path).st_size except FileNotFoundError: return 0 def resume_upload(local_file, server, remote_path, username, password=None, key_file=None): """ 断点续传文件到服务器 Args: local_file: 本地文件路径 server: 服务器地址 remote_path: 远程文件路径 username: 用户名 password: 密码(可选) key_file: SSH密钥文件(可选) """ # 获取本地文件大小 local_size = os.path.getsize(local_file) print(f"本地文件大小: {local_size / (1024**3):.2f} GB") # 连接服务器 print(f"连接到服务器 {server}...") ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) try: if key_file: ssh.connect(server, username=username, key_filename=key_file) elif password: ssh.connect(server, username=username, password=password) else: # 尝试使用默认的 SSH 密钥或 SSH agent ssh.connect(server, username=username) sftp = ssh.open_sftp() # 获取远程已传输的大小 remote_size = get_remote_file_size(sftp, remote_path) print(f"远程文件大小: {remote_size / (1024**3):.2f} GB") if remote_size >= local_size: print("文件已完全传输!") return # 断点续传 print(f"从 {remote_size / (1024**3):.2f} GB 处继续传输...") with open(local_file, 'rb') as local_fp: # 跳到断点位置 local_fp.seek(remote_size) # 以追加模式打开远程文件 with sftp.file(remote_path, 'ab') as remote_fp: # 创建进度条 with tqdm(total=local_size, initial=remote_size, unit='B', unit_scale=True, unit_divisor=1024, desc="上传进度") as pbar: # 分块上传 chunk_size = 1024 * 1024 # 1MB while True: chunk = local_fp.read(chunk_size) if not chunk: break remote_fp.write(chunk) pbar.update(len(chunk)) print("\n✓ 文件传输完成!") # 验证文件大小 final_remote_size = get_remote_file_size(sftp, remote_path) if final_remote_size == local_size: print(f"✓ 验证成功: 远程文件大小 {final_remote_size} == 本地文件大小 {local_size}") else: print(f"✗ 警告: 远程文件大小 {final_remote_size} != 本地文件大小 {local_size}") except Exception as e: print(f"错误: {e}") sys.exit(1) finally: sftp.close() ssh.close() if __name__ == "__main__": # 配置参数 LOCAL_FILE = r"D:\process_mp4.zip" SERVER = "74.48.179.187" REMOTE_PATH = "/root/process_mp4.zip" USERNAME = "root" # 检查本地文件是否存在 if not os.path.exists(LOCAL_FILE): print(f"错误: 本地文件不存在: {LOCAL_FILE}") sys.exit(1) print("=" * 60) print("断点续传工具") print("=" * 60) print(f"本地文件: {LOCAL_FILE}") print(f"服务器: {SERVER}") print(f"远程路径: {REMOTE_PATH}") print("=" * 60) print("\n提示: 需要输入服务器密码(如果没有配置SSH密钥)") # 提示输入密码(可选) import getpass password = getpass.getpass("请输入SSH密码(直接回车跳过,使用SSH密钥): ") if not password: password = None # 执行断点续传 resume_upload(LOCAL_FILE, SERVER, REMOTE_PATH, USERNAME, password=password)
2026-01-29
ms-swift
00

ms-swift swift export 出错样本会怎样

  • 某条样本在预处理时抛错(例如图片损坏 OSError: broken data stream when reading image file),会打出:There are errors in the dataset, the data will be deleted
  • “deleted” 指:这条样本不会写入本次 export 的 cached 数据集,相当于被过滤掉;不会删除你磁盘上的原始数据文件。
  • 想一出错就停、不自动跳过,可加参数:--strict
2026-01-29
DL论文
00

根据论文内容,让我详细解释视频和音频是如何输入模型并转换为 token 的:

🎬 视频输入处理

视频处理流程

展开代码
原始视频 → 视觉帧提取 + 音频提取 → 分别编码 → 时间对齐 → 输入 LLM
2026-01-27
Linux运维
00
2026-01-27
DL论文
00

1. 《Gemini 1.5: Unlocking multimodal underst

2026-01-25
DL论文
00

https://arxiv.org/html/2505.09970v2

让我用一个具体的对话客服场景来演示 Pre-Act 和 ReAct 的区别

场景:银行客户服务

用户查询:我想查询我的储蓄账户(尾号1234)余额,然后把5000元从储蓄账户转到我的信用卡(尾号5678)还款,最后告诉我转账后的储蓄账户余额。

可用的工具:

  1. check_balance(account_number) - 查询账户余额
  2. transfer_funds(from_account, to_account, amount) - 转账
  3. check_credit_card_balance(card_number) - 查询信用卡欠款
2026-01-24
深度学习
00
2026-01-24
深度学习
00

Hugging Face 仓库下载指南

核心要点

1. 区分仓库类型

  • 模型 (model): 默认类型,用于下载预训练模型
  • 数据集 (dataset): 必须指定 repo_type="dataset",用于下载数据集

关键经验: 如果作为 model 下载失败(401错误),立即尝试作为 dataset 下载。

2026-01-23
Linux运维
00

Podman安装配置经验沉淀文档

📋 文档目的

本文档用于指导AI助手在阿里PAI DSW(Kubernetes pod)环境中安装和配置Podman,包括持久化存储的处理方案。

2026-01-23
Linux运维
00
  1. 查看出站 IP: 运行以下命令,它会通过查询外部服务来显示你的公网出站地址:
    bash
    展开代码
    curl -s http://ipinfo.io/ip
    或者:
    bash
    展开代码
    curl -s http://ifconfig.me