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 Distribution

inoyb-1.1.21.tar.gz (56.0 kB view details)

Uploaded Source

Built Distribution

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

inoyb-1.1.21-py3-none-any.whl (64.3 kB view details)

Uploaded Python 3

File details

Details for the file inoyb-1.1.21.tar.gz.

File metadata

  • Download URL: inoyb-1.1.21.tar.gz
  • Upload date:
  • Size: 56.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for inoyb-1.1.21.tar.gz
Algorithm Hash digest
SHA256 c4897305e94c010b5539585acd118c7bd685211cf0c0d7544a80ae786b139c9f
MD5 1174f6fcb1281fc5ca70cb2cbe5b2f40
BLAKE2b-256 d69e1e3991538a66d8ac5beaddeff082525af01da11b09705b59f017c209f36a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: inoyb-1.1.21-py3-none-any.whl
  • Upload date:
  • Size: 64.3 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.21-py3-none-any.whl
Algorithm Hash digest
SHA256 878ff6f50e3e25e808a7752a1ae6d9c992a914315abecc932f346d2e4b641e26
MD5 252f798a297a8e725ce440ee5e7c6607
BLAKE2b-256 bb299181864c531763c56c50796fb8fb5f6e50fe2317ef19f238d10b81c6390b

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