当前位置: 首页 > news >正文

模型和数据集的平台之在Hugging Face上进行模型下载、上传以及创建专属Space

模型下载

步骤:

注册Hugging Face平台

https://huggingface.co/ 

新建一个hf_download_josn.py 文件

touch hf_download_josn.py

编写hf_download_josn.py文件

import os
from huggingface_hub import hf_hub_download

# 指定模型标识符
repo_id = "internlm/internlm2_5-7b"

# 指定要下载的文件列表
files_to_download = [
    {"filename": "config.json"},
    {"filename": "model.safetensors.index.json"}
]

# 创建一个目录来存放下载的文件
local_dir = f"{repo_id.split('/')[1]}"
os.makedirs(local_dir, exist_ok=True)

# 遍历文件列表并下载每个文件
for file_info in files_to_download:
    file_path = hf_hub_download(
        repo_id=repo_id,
        filename=file_info["filename"],
        local_dir=local_dir
    )
    print(f"{file_info['filename']} file downloaded to: {file_path}")

运行模型下载

python hf_download_josn.py

从Hugging Face上看下载了相应配置文件

模型上传

通过CLI上传 Hugging Face

curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
git lfs install # 直接在git环境下配置git LFS
pip install huggingface_hub

在CodeSpace里面,使用

git config --global credential.helper store
huggingface-cli login

创建项目

cd /workspaces/codespaces-jupyter

#创建项目
huggingface-cli repo create intern_study_L0_4


git clone https://huggingface.co/{your_huggingface_name}/intern_study_L0_4

把要上传的模型上传上去

git add .
git commit -m "add:intern_study_L0_4"
git push  origin

Hugging Face的个人profile里面看到这个mode

创建space

Spaces 使得开发者可以快速将我们的模型部署为可交互的 web 应用,且无需担心后端基础设施或部署的复杂性

https://huggingface.co/spaces

在右上角点击Create new Space进行创建

在创建页面中,输入项目名为intern_cobuild,并选择Static应用进行创建

 

在修改默认的html

克隆到本地修改默认html

git clone https://huggingface.co/spaces/<your_username>/intern_cobuild cd /workspaces/codespaces-jupyter/intern_cobuild

<!doctype html>
<html>
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width" />
  <title>My static Space</title>
  <style>
    html, body {
      margin: 0;
      padding: 0;
      height: 100%;
    }
    body {
      display: flex;
      justify-content: center;
      align-items: center;
    }
    iframe {
      width: 430px;
      height: 932px;
      border: none;
    }
  </style>
</head>
<body>
  <iframe src="https://colearn.intern-ai.org.cn/cobuild" title="description"></iframe>
</body>
</html>

推送代码的到HF

git add .

git commit -m "修改默认文件"

git push origin

进入到HF平台查看spaces

相关文章:

  • 数据存储:一文掌握存储数据到mysql的详细使用
  • HIVE SQL函数之比较函数
  • 51单片机编程学习笔记——LED原理图
  • uni-app 开发 App 、 H5 横屏签名(基于lime-signature)
  • SCIKIT-LEARN 决策树实现csv文档简单的推论预测
  • 分布式爬虫
  • drupal简介
  • 工作中遇到的EXCEL小问题:多行有间隔符的合并
  • 【二分查找】P9698 [GDCPC2023] Path Planning|普及
  • 【SimHash 实现查重功能】
  • 基于 JavaWeb 的 SSM+Maven 微信小程序快递柜管理系统设计和实现(源码+文档+部署讲解)
  • STM32F407ZGT6移植freeRTOS
  • java异步编程接口简介
  • WPF学习之Prism(二)
  • 【HarmonyOS Next】 鸿蒙应用useNormalizedOHMUrl详解
  • Day29 第八章 贪心算法 part02
  • 分布式主键生成服务
  • 医院HIS接入大模型:算力基础设施与训练能力的深度剖析与测算
  • 树莓集团:数字影像领航,开启未来影像变革
  • 【STL学习】(5)list
  • 滨江集团:一季度营收225.07亿元,净利润9.75亿元
  • 孕妇乘坐高铁突发临产,广西铁路部门协助送医平安产子
  • 许峰已任江苏省南京市副市长
  • 民营经济促进法出台,自今年5月20日起施行
  • 农业农村部:把住能繁母猪存栏量“总开关”,引导养殖场户优化母猪存栏结构、合理控制产能
  • 五一假期上海推出首批16条“市民健康路线”,这些健康提示请收好