mohammedxxxxq commited on
Commit
4caa20a
·
verified ·
1 Parent(s): 5abbbb4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -5,6 +5,22 @@ from transformers import pipeline
5
  model = pipeline("text-classification",
6
  model="CAMeL-Lab/bert-base-arabic-camelbert-da-sentiment")
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  def analyze(text):
9
  if not text.strip():
10
  return "الرجاء إدخال نص للتحليل"
 
5
  model = pipeline("text-classification",
6
  model="CAMeL-Lab/bert-base-arabic-camelbert-da-sentiment")
7
 
8
+ from fastapi import FastAPI
9
+ from pydantic import BaseModel
10
+
11
+ app = FastAPI()
12
+
13
+ class Item(BaseModel):
14
+ data: list
15
+
16
+ @app.post("/predict")
17
+ def predict(item: Item):
18
+ text = item.data[0]
19
+
20
+ # استدعاء دالة التحليل الموجودة عندك
21
+ result = analyze(text)
22
+
23
+ return {"data": [result]}
24
  def analyze(text):
25
  if not text.strip():
26
  return "الرجاء إدخال نص للتحليل"