husseinelsaadi commited on
Commit
8bf4fb3
·
verified ·
1 Parent(s): 28146f8

pin /predict api_name

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -272,12 +272,14 @@ with gr.Blocks(title="AI Image Detector — Real Photo or AI-Generated?",
272
  b, lab, h, n = predict(image)
273
  return b, lab, h, n, gr.update(visible=image is not None)
274
 
 
 
275
  outputs = [banner, label, heat, notes, details]
276
- btn.click(_run, inputs=inp, outputs=outputs)
277
- inp.upload(_run, inputs=inp, outputs=outputs)
278
  inp.clear(lambda: ("", gr.update(visible=False), gr.update(visible=False),
279
  gr.update(visible=False), gr.update(visible=False)),
280
- outputs=outputs)
281
 
282
  if __name__ == "__main__":
283
  demo.launch()
 
272
  b, lab, h, n = predict(image)
273
  return b, lab, h, n, gr.update(visible=image is not None)
274
 
275
+ # api_name is pinned: the endpoint is part of the public interface, and Gradio
276
+ # otherwise names it after whichever function happens to be wired up.
277
  outputs = [banner, label, heat, notes, details]
278
+ btn.click(_run, inputs=inp, outputs=outputs, api_name="predict")
279
+ inp.upload(_run, inputs=inp, outputs=outputs, api_name=False)
280
  inp.clear(lambda: ("", gr.update(visible=False), gr.update(visible=False),
281
  gr.update(visible=False), gr.update(visible=False)),
282
+ outputs=outputs, api_name=False)
283
 
284
  if __name__ == "__main__":
285
  demo.launch()