3D 機器學習課程文件

透過 API 執行

Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

透過 API 執行

Open In Colab

要透過 API 執行,請複製 LGM-tiny-api 空間,而不是 LGM-tiny 空間。此空間包含以下 app.py

import gradio as gr
from gradio_client import Client, file


def run(image_url):
    client = Client("dylanebert/LGM-tiny")
    image = file(image_url)
    result = client.predict(image, api_name="/predict")
    return result


demo = gr.Interface(
    fn=run,
    title="LGM Tiny API",
    description="An API wrapper for [LGM Tiny](https://huggingface.co/spaces/dylanebert/LGM-tiny). Intended as a resource for the [ML for 3D Course](https://huggingface.co/learn/ml-for-3d-course).",
    inputs=gr.Textbox(label="Image URL", placeholder="Enter image URL, e.g. https://huggingface.co/datasets/dylanebert/iso3d/resolve/main/jpg@512/a_cat_statue.jpg"),
    outputs=gr.Model3D(),
    examples=[
        "https://huggingface.co/datasets/dylanebert/iso3d/resolve/main/jpg@512/a_cat_statue.jpg"
    ],
    allow_duplication=True,
)
demo.queue().launch()

這將在 CPU 上執行,但依賴於原始 LGM-tiny 而不是您的自定義模型。但是,如果您的重點是 UI/UX 或下游任務,這可能是可以接受的。

< > 在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.