TymaaHammouda commited on
Commit
4061621
·
verified ·
1 Parent(s): 25f9a66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py CHANGED
@@ -7,6 +7,25 @@ from fastapi.responses import JSONResponse
7
  print("Version ---- 1")
8
  app = FastAPI()
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  from sinatools.relations.relation_extractor import relation_extraction
11
  from sinatools.relations.event_relation_extractor import event_argument_relation_extraction
12
 
 
7
  print("Version ---- 1")
8
  app = FastAPI()
9
 
10
+ from huggingface_hub import snapshot_download
11
+
12
+ # Path expected by sinatools
13
+ BASE_DIR = os.path.expanduser("~/.sinatools")
14
+ MODEL_DIR = os.path.join(BASE_DIR, "relation_model")
15
+
16
+ # Create directory
17
+ os.makedirs(BASE_DIR, exist_ok=True)
18
+
19
+ # Download model ONLY if not exists
20
+ if not os.path.exists(MODEL_DIR) or not os.listdir(MODEL_DIR):
21
+ snapshot_download(
22
+ repo_id="aaljabari/arabic-relation-extraction-model",
23
+ local_dir=MODEL_DIR,
24
+ local_dir_use_symlinks=False
25
+ )
26
+
27
+
28
+
29
  from sinatools.relations.relation_extractor import relation_extraction
30
  from sinatools.relations.event_relation_extractor import event_argument_relation_extraction
31