Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from inference import predict, predict_batch | |
| APP_TITLE = "# Fruit & Vegetable Classification" | |
| APP_DESC = """ | |
| Model CNN berbasis TensorFlow untuk 15 kelas sayur/buah dari dataset Fresh & Rotten. | |
| - Input : Foto RGB tunggal, otomatis di-resize ke ukuran input model. | |
| - Output : Probabilitas per kelas (Top-N dari gr.Label). | |
| - Catatan: Gunakan gambar close-up dengan satu objek utama untuk hasil terbaik. | |
| """ | |
| 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 image (fruit/vegetable)") | |
| out = gr.Label(num_top_classes=5, label="Predictions") | |
| with gr.Row(): | |
| btn = gr.Button("Predict", variant="primary") | |
| gr.ClearButton([inp, out]) | |
| 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() | |