import gradio as gr from inference import predict, predict_batch APP_TITLE = "# Face Shape Classification — EfficientNetB4 (300×300)" APP_DESC = """ Model EfficientNetB4 (ImageNet) fine-tuned pada 5 kelas: Heart, Oblong, Oval, Round, Square. • Input: Foto wajah frontal RGB (1 orang), auto-resize 300×300. • Output: Prediksi + confidence (Top-5). • Disclaimer: Untuk penelitian/edukasi. """ with gr.Blocks(theme=gr.themes.Soft()) as demo: gr.Markdown(APP_TITLE) gr.Markdown(APP_DESC) with gr.Row(): inp = gr.Image(type="pil", label="Upload face (frontal)") out = gr.Label(num_top_classes=5, label="Predictions") with gr.Row(): btn = gr.Button("Predict", variant="primary") gr.ClearButton([inp, out]) # Expose stable API names for @gradio/client consumers btn.click(predict, inputs=inp, outputs=out, api_name="predict") with gr.Tab("Batch (optional)"): gal = gr.Gallery(label="Images", columns=4, height="auto") out_gal = gr.JSON(label="Batch outputs") runb = gr.Button("Run batch") runb.click(predict_batch, inputs=gal, outputs=out_gal, api_name="predict_batch") if __name__ == "__main__": demo.launch()