Spaces:
Running
Running
File size: 898 Bytes
30158dd 976e547 30158dd 976e547 30158dd 976e547 30158dd 976e547 30158dd 976e547 30158dd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# app.py
import gradio as gr
from handler import EndpointHandler
# 初始化你的 ONNX 模型
handler = EndpointHandler(path=".")
def api_call(image, return_embeddings_only):
data = {
"inputs": image, # PIL.Image
"parameters": {"return_embeddings_only": return_embeddings_only}
}
result = handler(data)[0]
# If embeddings file is returned
if "file" in result:
return result["file"]
return result # JSON only(含 base64 mask)
demo = gr.Interface(
fn=api_call,
inputs=[
gr.Image(type="pil", label="image"),
gr.Checkbox(label="Return embeddings only (as .bin file)", value=True)
],
outputs=[gr.File(label="embeddings.bin or result JSON")],
title="Edge SAM Encoder API",
description="Send image, get embeddings in float32 binary format (.bin file)."
)
if __name__ == "__main__":
demo.launch()
|