slope / app.py
Isaiah6b's picture
Deploy space_slope from monorepo
e9e1e05 verified
Raw
History Blame Contribute Delete
656 Bytes
"""Gradio demo: linear slope y = wx + b via ONNX Runtime."""
import gradio as gr
import numpy as np
import onnxruntime as ort
session = ort.InferenceSession("slope.onnx")
def predict(x_val: float) -> float:
x = np.array([[x_val]], dtype=np.float32)
outputs = session.run(None, {"x": x})
return float(outputs[0][0, 0])
demo = gr.Interface(
fn=predict,
inputs=gr.Number(label="x", value=2.0),
outputs=gr.Number(label="y = wx + b"),
title="ONNX Slope Demo",
description=(
"PyTorch-trained linear model exported to ONNX. "
"Trained on y ≈ 2x + 1; enter x to get the predicted y."
),
)
demo.launch()