Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,16 +8,26 @@ import numpy as np
|
|
| 8 |
import zipfile
|
| 9 |
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
zip_path =
|
| 13 |
-
extract_dir = os.path.join(os.getcwd(), "en_core_web_sm")
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
| 17 |
zip_ref.extractall(extract_dir)
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# Carica il modello
|
| 20 |
-
nlp = spacy.load(extract_dir)
|
|
|
|
| 21 |
|
| 22 |
# Carica il modello SentenceTransformer
|
| 23 |
model = SentenceTransformer('sentence-transformers/all-mpnet-base-v2', device='cpu')
|
|
|
|
| 8 |
import zipfile
|
| 9 |
|
| 10 |
|
| 11 |
+
# Percorso del file ZIP
|
| 12 |
+
zip_path = '/home/user/app/en_core_web_sm-3.0.0.zip' # Assicurati che il percorso sia corretto
|
|
|
|
| 13 |
|
| 14 |
+
# Verifica se il file esiste
|
| 15 |
+
if os.path.exists(zip_path):
|
| 16 |
+
# Directory di estrazione
|
| 17 |
+
extract_dir = '/home/user/app/en_core_web_sm' # Dove vuoi estrarre il modello
|
| 18 |
+
|
| 19 |
+
# Estrai il file ZIP
|
| 20 |
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
| 21 |
zip_ref.extractall(extract_dir)
|
| 22 |
|
| 23 |
+
# Carica il modello Spacy
|
| 24 |
+
spacy.cli.link(extract_dir, 'en_core_web_sm')
|
| 25 |
+
else:
|
| 26 |
+
print(f"Il file {zip_path} non è stato trovato!")
|
| 27 |
+
|
| 28 |
# Carica il modello
|
| 29 |
+
#nlp = spacy.load(extract_dir)
|
| 30 |
+
nlp = spacy.load('en_core_web_sm')
|
| 31 |
|
| 32 |
# Carica il modello SentenceTransformer
|
| 33 |
model = SentenceTransformer('sentence-transformers/all-mpnet-base-v2', device='cpu')
|