Skip to main content

极其友好的地理空间AI模型服务框架 - Docker化部署,支持Gradio界面

Project description

inoyb

inoyb - 基于mc.json配置的Gradio模型服务框架

简介

inoyb是一个轻量级的Python框架,用于快速构建基于Gradio的机器学习模型服务。通过简单的配置文件和装饰器,您可以轻松地将模型推理代码转换为Web服务。

特性

  • 🚀 一键部署: 使用@your_turn()装饰器即可将模型函数转换为Web服务
  • 📋 配置驱动: 通过mc.json配置文件定义输入输出界面
  • 🔧 智能执行: 支持隔离工作空间和并发执行
  • 📁 文件管理: 智能大文件检测和符号链接优化
  • 🎨 美观界面: 基于Gradio构建的现代化Web界面
  • 📊 预览支持: 自动生成地理数据预览图
  • 🗂️ 文件夹浏览: 支持文件夹输出的在线浏览

快速开始

安装

pip install inoyb

基本使用

  1. 创建模型服务文件 gogogo.py:
from inoyb import your_turn

@your_turn()
def model_handler(*inputs):
    return [
        "python", "model/inference.py",
        "--data_files", inputs[0], inputs[1], inputs[2],
        "--config_path", "model/config.json",
        "--checkpoint", "model/Prithvi_EO_V1_100M.pt"
    ]

if __name__ == "__main__":
    model_handler.run()
  1. 创建配置文件 mc.json:
{
  "model_info": {
    "name": "Prithvi地理空间基础模型",
    "description": "基于卫星图像的地理空间分析模型",
    "version": "1.0.0"
  },
  "inputs": {
    "hls_data": {
      "type": "geodata",
      "label": "HLS数据文件",
      "required": true,
      "file_types": [".tif", ".tiff"]
    },
    "mask_data": {
      "type": "geodata", 
      "label": "掩码数据文件",
      "required": true,
      "file_types": [".tif", ".tiff"]
    }
  },
  "outputs": {
    "prediction": {
      "type": "geodata",
      "label": "预测结果",
      "required": true,
      "file_types": [".tif"],
      "bands": [3, 2, 1]
    }
  }
}
  1. 运行服务:
python gogogo.py

装饰器参数

  • mc_json: 配置文件路径 (默认: "mc.json")
  • port: 服务端口 (默认: 从环境变量读取)
  • example_path: 示例数据路径 (默认: "examples")
  • output_dir: 输出目录 (默认: "outputs")

项目结构

your-project/
├── gogogo.py          # 模型服务启动文件
├── mc.json           # 配置文件
├── model/            # 模型文件夹
│   ├── inference.py  # 模型推理脚本
│   ├── config.json   # 模型配置
│   └── weights.pt    # 模型权重
├── examples/         # 示例数据(可选)
└── outputs/          # 输出目录

配置说明

mc.json结构

  • model_info: 模型基本信息
  • inputs: 输入字段定义
  • outputs: 输出字段定义

支持的数据类型

  • geodata: 地理空间数据(.tif, .tiff等)
  • file: 普通文件
  • folder: 文件夹
  • text: 文本输入

高级特性

大文件优化

框架自动检测大文件(>200MB)并使用符号链接优化存储空间,避免不必要的文件复制。

并发支持

支持多用户并发访问,每个请求在独立的工作空间中执行,互不干扰。

预览生成

对于地理数据输出,自动生成预览图片,支持自定义波段组合。

开发

安装开发依赖

pip install -e ".[dev]"

运行测试

pytest

代码格式化

black inoyb/

许可证

MIT License

贡献

欢迎提交Issue和Pull Request!

作者

DiChen - dichen@example.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

inoyb-1.1.2-py3-none-any.whl (65.2 kB view details)

Uploaded Python 3

File details

Details for the file inoyb-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: inoyb-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 65.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for inoyb-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 88aae197c51a6876f00bcb89f7ab3d736dfa7f2c8b068ab9599e117c92f7bc96
MD5 604c78164ddc659cedc4eac30fdad52c
BLAKE2b-256 f5a744c2da81a4971f2fb48f92171795ea362db5a7f6f262c24a5eb283400055

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page