-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
30 lines (25 loc) · 976 Bytes
/
Copy pathapp.py
File metadata and controls
30 lines (25 loc) · 976 Bytes
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
"""Gradio demo: type an ingredient, get its lifecycle-stage diagnosis."""
import gradio as gr
from src.diagnose import diagnose
def run(ingredient):
if not ingredient or not ingredient.strip():
return "Type an ingredient (e.g. pandan).", "", None
try:
headline, rationale, prob, chart = diagnose(ingredient.strip())
return headline, f"{rationale}\n\n(early-curve match: {prob:.0%})", chart
except Exception as e:
return "Could not diagnose this ingredient.", str(e), None
demo = gr.Interface(
fn=run,
inputs=gr.Textbox(label="Ingredient", placeholder="pandan"),
outputs=[
gr.Textbox(label="Diagnosis"),
gr.Textbox(label="Why"),
gr.Plot(label="Google Trends"),
],
title="NextOnMenu — Is it the next matcha?",
description="Diagnoses where a food ingredient sits in its trend lifecycle. "
"Radar, not crystal ball.",
)
if __name__ == "__main__":
demo.launch()