import gradio as gr from inference import predict from PIL import Image import io def predict_image(img: Image.Image): with io.BytesIO() as buffer: img.save(buffer, format="JPEG") img_bytes = buffer.getvalue() return predict(img_bytes) iface = gr.Interface( fn=predict_image, inputs=gr.Image(type="pil"), outputs=gr.JSON(), title="Sitting Posture Detection", description="Upload an image to detect sitting postures using YOLOv8" ) if __name__ == "__main__": iface.launch()