Spaces:
Running
Running
kwabs22
commited on
Commit
β’
955763d
1
Parent(s):
5abdcce
Convert space to docker sdk and update code
Browse files- Dockerfile +47 -0
- README.md +2 -4
- app.py +9 -8
- requirements.txt +2 -0
Dockerfile
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9
|
2 |
+
|
3 |
+
WORKDIR /code
|
4 |
+
|
5 |
+
# Install dependencies for OpenCV
|
6 |
+
RUN apt-get update && apt-get install -y \
|
7 |
+
libgl1-mesa-glx \
|
8 |
+
&& rm -rf /var/lib/apt/lists/*
|
9 |
+
|
10 |
+
# Create a virtual environment and activate it
|
11 |
+
RUN python -m venv /opt/venv
|
12 |
+
ENV PATH="/opt/venv/bin:$PATH"
|
13 |
+
|
14 |
+
COPY ./requirements.txt /code/requirements.txt
|
15 |
+
|
16 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
17 |
+
|
18 |
+
# Download Spacy models
|
19 |
+
RUN python -m spacy download en_core_web_sm
|
20 |
+
RUN python -m spacy download ko_core_news_sm
|
21 |
+
RUN python -m spacy download ja_core_news_sm
|
22 |
+
RUN python -m spacy download zh_core_web_sm
|
23 |
+
RUN python -m spacy download es_core_news_sm
|
24 |
+
RUN python -m spacy download de_core_news_sm
|
25 |
+
|
26 |
+
# Set up a new user named "user" with user ID 1000
|
27 |
+
RUN useradd -m -u 1000 user
|
28 |
+
# Switch to the "user" user
|
29 |
+
USER user
|
30 |
+
# Set home to the user's home directory
|
31 |
+
ENV HOME=/home/user \
|
32 |
+
PATH=/home/user/.local/bin:$PATH \
|
33 |
+
PYTHONPATH=$HOME/app \
|
34 |
+
PYTHONUNBUFFERED=1 \
|
35 |
+
GRADIO_ALLOW_FLAGGING=never \
|
36 |
+
GRADIO_NUM_PORTS=1 \
|
37 |
+
GRADIO_SERVER_NAME=0.0.0.0 \
|
38 |
+
GRADIO_THEME=huggingface \
|
39 |
+
SYSTEM=spaces
|
40 |
+
|
41 |
+
# Set the working directory to the user's home directory
|
42 |
+
WORKDIR $HOME/app
|
43 |
+
|
44 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
45 |
+
COPY --chown=user . $HOME/app
|
46 |
+
|
47 |
+
CMD ["python", "app.py"]
|
README.md
CHANGED
@@ -3,10 +3,8 @@ title: Language Learn Idea
|
|
3 |
emoji: π
|
4 |
colorFrom: green
|
5 |
colorTo: yellow
|
6 |
-
sdk:
|
7 |
-
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
fullWidth: true
|
11 |
---
|
12 |
|
|
|
3 |
emoji: π
|
4 |
colorFrom: green
|
5 |
colorTo: yellow
|
6 |
+
sdk: docker
|
7 |
+
pinned: true
|
|
|
|
|
8 |
fullWidth: true
|
9 |
---
|
10 |
|
app.py
CHANGED
@@ -67,12 +67,13 @@ nltk.download('averaged_perceptron_tagger') #Parts of Speech Tagging
|
|
67 |
nltk.download('udhr') # Declaration of Human rights in many languages
|
68 |
|
69 |
|
70 |
-
spacy.cli.download("en_core_web_sm")
|
71 |
-
spacy.cli.download('ko_core_news_sm')
|
72 |
-
spacy.cli.download('ja_core_news_sm')
|
73 |
-
spacy.cli.download('zh_core_web_sm')
|
74 |
-
spacy.cli.download("es_core_news_sm")
|
75 |
-
spacy.cli.download("de_core_news_sm")
|
|
|
76 |
|
77 |
nlp_en = spacy.load("en_core_web_sm")
|
78 |
nlp_de = spacy.load("de_core_news_sm")
|
@@ -1932,7 +1933,7 @@ def letterbased_guess_word(target, guess):
|
|
1932 |
|
1933 |
#----------------------------------------------------------------------------------------------------------------------------
|
1934 |
|
1935 |
-
speedmastery_load_imagesinput = gr.Files(file_count="multiple", type="binary"
|
1936 |
|
1937 |
def speedmastery_load_images(image_files):
|
1938 |
#return [image_file for image_file in image_files]
|
@@ -2425,4 +2426,4 @@ Each type of knowing involves different cognitive processes and levels of unders
|
|
2425 |
gr.Textbox(label='Use this text to hold translations of the SQL rows in the above linked dataset (A kind of What I say vs what I want)')
|
2426 |
|
2427 |
|
2428 |
-
lliface.queue().launch() #(inbrowser="true")
|
|
|
67 |
nltk.download('udhr') # Declaration of Human rights in many languages
|
68 |
|
69 |
|
70 |
+
#spacy.cli.download("en_core_web_sm") #download in the docker file
|
71 |
+
#spacy.cli.download('ko_core_news_sm')
|
72 |
+
#spacy.cli.download('ja_core_news_sm')
|
73 |
+
#spacy.cli.download('zh_core_web_sm')
|
74 |
+
#spacy.cli.download("es_core_news_sm")
|
75 |
+
#spacy.cli.download("de_core_news_sm")
|
76 |
+
#print(spacy.info()) #Docker install path debugging
|
77 |
|
78 |
nlp_en = spacy.load("en_core_web_sm")
|
79 |
nlp_de = spacy.load("de_core_news_sm")
|
|
|
1933 |
|
1934 |
#----------------------------------------------------------------------------------------------------------------------------
|
1935 |
|
1936 |
+
speedmastery_load_imagesinput = gr.Files(file_count="multiple", type="binary") #, file_types='image')
|
1937 |
|
1938 |
def speedmastery_load_images(image_files):
|
1939 |
#return [image_file for image_file in image_files]
|
|
|
2426 |
gr.Textbox(label='Use this text to hold translations of the SQL rows in the above linked dataset (A kind of What I say vs what I want)')
|
2427 |
|
2428 |
|
2429 |
+
lliface.queue().launch(share=True) #(inbrowser="true")
|
requirements.txt
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
spacy
|
2 |
nltk
|
3 |
wikipedia
|
|
|
1 |
+
torch
|
2 |
+
transformers
|
3 |
spacy
|
4 |
nltk
|
5 |
wikipedia
|