Select your language

Reacts: With Jax

@app.post("/predict") async def predict(file: UploadFile = File(...)): img = Image.open(file.file).resize((224, 224)) img_array = np.array(img) / 255.0 jax_input = preprocess_image(img_array) output = predict_jax(jax_input) # jax array return "prediction": float(output) # convert to Python float

const handleFileChange = async (e: React.ChangeEvent<HTMLInputElement>) => const file = e.target.files?.[0]; if (!file) return; Reacts With Jax

setLoading(true); const formData = new FormData(); formData.append('file', file); const file = e.target.files?.[0]

// ImageClassifier.tsx import React, useState from 'react'; export const ImageClassifier = () => null>(null); const [loading, setLoading] = useState(false); if (!file) return

const response = await fetch('http://localhost:8000/predict', method: 'POST', body: formData, ); const data = await response.json(); setPrediction(data.prediction); setLoading(false); ;

© 2025 Sevérina & Norbert Kümin

Disclaimer (german only)