Spaces:
Paused
Paused
Create models/model_loader.py
Browse files- models/model_loader.py +27 -0
models/model_loader.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
محمّل النماذج
|
3 |
+
يقوم بتحميل وإدارة نماذج الذكاء الاصطناعي المستخدمة في النظام
|
4 |
+
"""
|
5 |
+
|
6 |
+
import os
|
7 |
+
import logging
|
8 |
+
import torch
|
9 |
+
import gc
|
10 |
+
from typing import Dict, Any, Optional, Union, List
|
11 |
+
from pathlib import Path
|
12 |
+
|
13 |
+
logger = logging.getLogger(__name__)
|
14 |
+
|
15 |
+
class ModelLoader:
|
16 |
+
"""
|
17 |
+
محمّل النماذج
|
18 |
+
"""
|
19 |
+
|
20 |
+
def __init__(self, config=None, use_gpu=True):
|
21 |
+
"""
|
22 |
+
تهيئة محمّل النماذج
|
23 |
+
|
24 |
+
المعاملات:
|
25 |
+
----------
|
26 |
+
config : Dict, optional
|
27 |
+
إ
|