Linux 使用 Python 下载 Hugging Face 模型文件
你可以使用 wget 命令在 Linux 上直接下载文件。以下是使用 Python 和 wget 下载文件的示例代码:
import subprocess
url = 'https://huggingface.co/sail/dl/resolve/main/convformer/convformer_b36_in21ft1k.pth'
output_file = 'convformer_b36_in21ft1k.pth'
# 使用wget下载文件
download_command = f'wget {url} -O {output_file}'
subprocess.call(download_command, shell=True)
运行此代码将从给定的 URL 下载文件并将其保存为 convformer_b36_in21ft1k.pth。请确保你的系统安装了 wget 命令。如果没有安装,请使用以下命令进行安装:
sudo apt-get install wget
请注意,这只是一个示例代码,你可以根据自己的需求进行修改。
原文地址: https://www.cveoy.top/t/topic/qzq5 著作权归作者所有。请勿转载和采集!