mednow commited on
Commit
0c16581
·
verified ·
1 Parent(s): 851bea0

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +8 -6
  2. dockerfile +13 -28
  3. requirements.txt +1 -0
app.py CHANGED
@@ -103,15 +103,17 @@ abbreviations = {
103
  }
104
 
105
 
106
- def ensure_model_installed(model_name="en_core_web_sm"):
107
- if not os.path.exists(spacy.util.get_model_path(model_name)):
108
- print(f"Model {model_name} not found. Downloading...")
109
- spacy.cli.download(model_name)
110
- else:
111
- print(f"Model {model_name} is already installed.")
112
 
 
 
 
 
 
 
 
113
  # Ensure the model is installed
114
  ensure_model_installed()
 
115
  nlp = spacy.load("en_core_web_sm")
116
 
117
  def expand_abbreviations(text, abbreviations):
 
103
  }
104
 
105
 
 
 
 
 
 
 
106
 
107
+ def ensure_model_installed():
108
+ try:
109
+ spacy.load('en_core_web_sm')
110
+ except OSError:
111
+ from spacy.cli import download
112
+ download('en_core_web_sm')
113
+ spacy.load('en_core_web_sm')
114
  # Ensure the model is installed
115
  ensure_model_installed()
116
+
117
  nlp = spacy.load("en_core_web_sm")
118
 
119
  def expand_abbreviations(text, abbreviations):
dockerfile CHANGED
@@ -1,36 +1,21 @@
1
- # Use a base image with Python 3.10
2
- FROM python:3.10-slim
3
 
4
- # Set the working directory
5
- WORKDIR /home/user/app
6
 
7
- # Install system dependencies
8
- RUN apt-get update && apt-get install -y \
9
- git \
10
- git-lfs \
11
- ffmpeg \
12
- libsm6 \
13
- libxext6 \
14
- cmake \
15
- rsync \
16
- libgl1-mesa-glx \
17
- && rm -rf /var/lib/apt/lists/* \
18
- && git lfs install
19
-
20
- # Copy the requirements file
21
- COPY requirements.txt /tmp/requirements.txt
22
 
23
  # Install Python dependencies
24
- RUN pip install --no-cache-dir -r /tmp/requirements.txt
25
-
26
- # Install the SpaCy model
27
- RUN python -m spacy download en_core_web_sm
28
 
29
- # Copy the rest of the application code
30
- COPY . /home/user/app
 
31
 
32
- # Expose the port Streamlit is running on
33
- EXPOSE 8501
34
 
35
- # Run the Streamlit application
36
  CMD ["streamlit", "run", "app.py"]
 
1
+ # Use a base image with Python installed
2
+ FROM python:3.9-slim
3
 
4
+ # Set working directory
5
+ WORKDIR /app
6
 
7
+ # Copy requirements file to the container
8
+ COPY requirements.txt .
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  # Install Python dependencies
11
+ RUN pip install --no-cache-dir -r requirements.txt
 
 
 
12
 
13
+ # Install SpaCy and the en_core_web_sm model
14
+ RUN pip install --no-cache-dir spacy && \
15
+ python -m spacy download en_core_web_sm
16
 
17
+ # Copy the rest of your Streamlit application code to the container
18
+ COPY . .
19
 
20
+ # Set the entry point for the application
21
  CMD ["streamlit", "run", "app.py"]
requirements.txt CHANGED
@@ -7,3 +7,4 @@ tensorflow
7
  # https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0.tar.gz
8
  spacy
9
  https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0-py3-none-any.whl
 
 
7
  # https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0.tar.gz
8
  spacy
9
  https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0-py3-none-any.whl
10
+ pandas