File size: 1,219 Bytes
318b10c
8343674
a722bd4
ec4fcee
 
8343674
 
 
 
 
ec4fcee
 
318b10c
ec4fcee
 
 
318b10c
 
 
d2f7145
ec4fcee
 
 
a722bd4
8343674
 
ec4fcee
 
8343674
318b10c
 
8343674
a722bd4
318b10c
 
8343674
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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()