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.19.tar.gz (55.9 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.19-py3-none-any.whl (64.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: inoyb-1.1.19.tar.gz
  • Upload date:
  • Size: 55.9 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.19.tar.gz
Algorithm Hash digest
SHA256 8bdd6924a0400680ff17ad2eafc87ca9efb0c3e382eef8a8a12262a2758dd5c5
MD5 a449d4c84d096397f6d5b1c87be16406
BLAKE2b-256 ee0978dfce3b79869d6c5929fd8aa80b151c1c005c44cb68db1f43956dded32f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: inoyb-1.1.19-py3-none-any.whl
  • Upload date:
  • Size: 64.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.19-py3-none-any.whl
Algorithm Hash digest
SHA256 735e83411e21c7459e5d9fe4c54a834f47b23523b6d72c94b3e886dc5650bd32
MD5 93b2a0008727d3bc0be9297285edc17e
BLAKE2b-256 27cdb991c2ba8375a31ab397bb744b4942e81a28f7ab2a118c493b670c390e72

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