Skip to content

Commit

Permalink
#21 provide DeepPavlov folder. Refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolay-r committed Apr 17, 2022
1 parent 4310f18 commit 4f0d232
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
7 changes: 6 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@ COPY arelight /arelight
RUN ls -la
RUN pip install /arelight/. -r /arelight/dependencies.txt

# Download DeepPavlov resources in advance.
COPY deeppavlov_data.sh /deeppavlov_data.sh
RUN chmod +x deeppavlov_data.sh
RUN /deeppavlov_data.sh

# Download required resources.
RUN python /arelight/download.py

EXPOSE 80

# Setup apache configs.
RUN apt-get clean && apt-get update && apt-get install -y apache2 python
RUN apt-get clean && apt-get update && apt-get install -y apache2 python unzip
RUN a2enmod cgi
RUN echo export PATH=/root/.pyenv/shims:/root/.pyenv/bin:$PATH >> /etc/apache2/envvars

Expand Down
26 changes: 26 additions & 0 deletions docker/deeppavlov_data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This is required since DeepPavlov downloader might not work.

# Apache server demo dir.
demo_dir="/var/www/demo/"

# Assigning remote URLs.
ner_model_url="http://files.deeppavlov.ai/deeppavlov_data/ner_ontonotes_bert_mult_v1.tar.gz"
bert_model_url="http://files.deeppavlov.ai/deeppavlov_data/bert/multi_cased_L-12_H-768_A-12.zip"

# Donwload models.
wget $(ner_model_url)
wget $(bert_model_url)

# Unpacking models.
tar -xvf ner_ontonotes_bert_mult_v1.tar.gz
unzip multi_cased_L-12_H-768_A-12.zip
rm ner_ontonotes_bert_mult_v1
rm multi_cased_L-12_H-768_A-12

# Prepare target folders.
mkdir -p "$(demo_dir).deeppavlov/models/"
mkdir -p "$(demo_dir).deeppavlov/downloads/bert_models/"

# Moving models.
mv "ner_ontonotes_bert_mult_v1" "$(demo_dir).deeppavlov/models/"
mv "multi_cased_L-12_H-768_A-12" "$(demo_dir).deeppavlov/downloads/bert_models/"
2 changes: 1 addition & 1 deletion examples/demo/wui.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def prepare_template(data, text, bratUrl):
cgi_output(template)
exit(0)

brat_json = demo_infer_texts_bert(text=text,
brat_json = demo_infer_texts_bert(text=text.strip(),
model_dir="/arelight/data/models",
output_dir=".",
state_name="ra-20-srubert-large-neut-nli-pretrained-3l",
Expand Down

0 comments on commit 4f0d232

Please sign in to comment.