GhadaAlothman commited on
Commit
16880fb
·
verified ·
1 Parent(s): 93b15bf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -50,15 +50,17 @@ def analyze_text(text):
50
  stats = compute_metrics(text)
51
  return {"Predicted_Label": label, **stats}
52
 
53
- # ✅ This single interface handles both UI and API:
54
  demo = gr.Interface(
55
  fn=analyze_text,
56
  inputs=gr.Textbox(label="أدخل النص العربي هنا", lines=6),
57
  outputs=gr.JSON(label="نتائج التحليل"),
58
- api_name="predict", # important for your frontend to call /run/predict
59
  title="Arabic Readability Analyzer",
60
  description="أداة ذكية لتقييم مقروئية النصوص العربية باستخدام نموذج AraBERT."
61
  )
62
 
63
- # ✅ Launch the Space with CORS enabled
64
- demo.launch(server_name="0.0.0.0", server_port=7860, allowed_origins=["*"])
 
 
 
50
  stats = compute_metrics(text)
51
  return {"Predicted_Label": label, **stats}
52
 
53
+ # ✅ This creates a Space API endpoint
54
  demo = gr.Interface(
55
  fn=analyze_text,
56
  inputs=gr.Textbox(label="أدخل النص العربي هنا", lines=6),
57
  outputs=gr.JSON(label="نتائج التحليل"),
58
+ api_name="predict",
59
  title="Arabic Readability Analyzer",
60
  description="أداة ذكية لتقييم مقروئية النصوص العربية باستخدام نموذج AraBERT."
61
  )
62
 
63
+ # ✅ Launch safely (Gradio v4+)
64
+ if __name__ == "__main__":
65
+ demo.queue()
66
+ demo.launch(server_name="0.0.0.0", server_port=7860)