ExistedYear commited on
Commit
39f735d
·
1 Parent(s): 2b3d6c9

fix gradio6 launch: single Blocks with api_name predict

Browse files
Files changed (1) hide show
  1. app.py +1 -17
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import sys, os
2
  sys.path.insert(0, os.path.join(os.path.dirname(__file__), "smishing_detector"))
3
 
4
- import json
5
  import gradio as gr
6
  import spaces
7
  from predictor import SmishingPredictor
@@ -136,7 +135,7 @@ with gr.Blocks(title="ScamShield — Smishing Detector") as demo:
136
  with gr.TabItem("SHAP Explainability"):
137
  shap_box = gr.Markdown()
138
 
139
- btn.click(fn=analyze, inputs=inp, outputs=[verdict, url_box, text_box, shap_box])
140
  inp.submit(fn=analyze, inputs=inp, outputs=[verdict, url_box, text_box, shap_box])
141
 
142
  gr.Examples(examples=examples, inputs=inp, label="Try these examples")
@@ -147,21 +146,6 @@ with gr.Blocks(title="ScamShield — Smishing Detector") as demo:
147
  "**Features:** 9 URL signals + 8 text signals | **F1:** 0.98")
148
 
149
 
150
- @spaces.GPU
151
- def api_predict(message: str) -> str:
152
- return json.dumps(predictor.predict(message), ensure_ascii=False)
153
-
154
-
155
- api = gr.Interface(
156
- fn=api_predict,
157
- inputs=gr.Textbox(label="message"),
158
- outputs=gr.Textbox(label="result"),
159
- api_name="predict",
160
- title="ScamShield API",
161
- )
162
-
163
-
164
  if __name__ == "__main__":
165
  demo.queue(default_concurrency_limit=1)
166
- gr.mount_gradio_app(demo, api, path="/api")
167
  demo.launch()
 
1
  import sys, os
2
  sys.path.insert(0, os.path.join(os.path.dirname(__file__), "smishing_detector"))
3
 
 
4
  import gradio as gr
5
  import spaces
6
  from predictor import SmishingPredictor
 
135
  with gr.TabItem("SHAP Explainability"):
136
  shap_box = gr.Markdown()
137
 
138
+ btn.click(fn=analyze, inputs=inp, outputs=[verdict, url_box, text_box, shap_box], api_name="predict")
139
  inp.submit(fn=analyze, inputs=inp, outputs=[verdict, url_box, text_box, shap_box])
140
 
141
  gr.Examples(examples=examples, inputs=inp, label="Try these examples")
 
146
  "**Features:** 9 URL signals + 8 text signals | **F1:** 0.98")
147
 
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  if __name__ == "__main__":
150
  demo.queue(default_concurrency_limit=1)
 
151
  demo.launch()