Sanjayraju30 commited on
Commit
a2b18be
·
verified ·
1 Parent(s): dfcd009

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -5,7 +5,7 @@ from risk_model import predict_risk, retrain_model, get_history_df
5
  # Create FastAPI instance
6
  fastapi_app = FastAPI()
7
 
8
- # Create Gradio app
9
  gradio_app = gr.Blocks()
10
 
11
  with gradio_app:
@@ -23,7 +23,10 @@ with gradio_app:
23
  score = gr.Textbox(label="Confidence (%)")
24
  retrain_output = gr.Textbox(label="Retrain Status")
25
 
26
- history_table = gr.Dataframe(headers=["Temperature", "Duration", "Risk", "Confidence"], label="📈 Prediction History")
 
 
 
27
 
28
  def classify(temp, duration):
29
  if temp <= 0 or duration <= 0:
@@ -35,10 +38,10 @@ with gradio_app:
35
  predict_btn.click(classify, inputs=[temp, duration], outputs=[result, score, history_table])
36
  retrain_btn.click(retrain_model, outputs=[retrain_output])
37
 
38
- # Optional: basic route to test API is up
39
  @fastapi_app.get("/")
40
  def root():
41
- return {"status": "Heating Mantle API is live"}
42
 
43
- # ✅ Hugging Face requires this line exactly
44
  app = gr.mount_gradio_app(fastapi_app, gradio_app, path="/predict-ui")
 
5
  # Create FastAPI instance
6
  fastapi_app = FastAPI()
7
 
8
+ # Gradio UI blocks
9
  gradio_app = gr.Blocks()
10
 
11
  with gradio_app:
 
23
  score = gr.Textbox(label="Confidence (%)")
24
  retrain_output = gr.Textbox(label="Retrain Status")
25
 
26
+ history_table = gr.Dataframe(
27
+ headers=["Temperature", "Duration", "Risk", "Confidence"],
28
+ label="📈 Prediction History"
29
+ )
30
 
31
  def classify(temp, duration):
32
  if temp <= 0 or duration <= 0:
 
38
  predict_btn.click(classify, inputs=[temp, duration], outputs=[result, score, history_table])
39
  retrain_btn.click(retrain_model, outputs=[retrain_output])
40
 
41
+ # Optional test route
42
  @fastapi_app.get("/")
43
  def root():
44
+ return {"message": "Heating Mantle FastAPI is working"}
45
 
46
+ # ✅ Hugging Face requires this:
47
  app = gr.mount_gradio_app(fastapi_app, gradio_app, path="/predict-ui")