ArxAlfa
commited on
Commit
•
9d63bd4
1
Parent(s):
aad9eca
Fix Dockerfile formatting and remove unused code
Browse files- Dockerfile +5 -5
- app.py +1 -13
- docker-compose.yml +13 -0
- requirements.txt +1 -1
Dockerfile
CHANGED
@@ -10,17 +10,17 @@ COPY ./requirements.txt /code/requirements.txt
|
|
10 |
# Install requirements.txt
|
11 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
12 |
|
13 |
-
# Set up a new user named "user" with user ID 1000
|
14 |
RUN useradd -m -u 1000 user
|
15 |
-
# Switch to the "user" user
|
16 |
USER user
|
17 |
-
# Set home to the user's home directory
|
18 |
ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
|
19 |
|
20 |
-
# Set the working directory to the user's home directory
|
21 |
WORKDIR $HOME/app
|
22 |
|
23 |
-
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
24 |
COPY --chown=user . $HOME/app
|
25 |
|
26 |
# Start the FastAPI app on port 7860, the default port expected by Spaces
|
|
|
10 |
# Install requirements.txt
|
11 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
12 |
|
13 |
+
# # Set up a new user named "user" with user ID 1000
|
14 |
RUN useradd -m -u 1000 user
|
15 |
+
# # Switch to the "user" user
|
16 |
USER user
|
17 |
+
# # Set home to the user's home directory
|
18 |
ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
|
19 |
|
20 |
+
# # Set the working directory to the user's home directory
|
21 |
WORKDIR $HOME/app
|
22 |
|
23 |
+
# # Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
24 |
COPY --chown=user . $HOME/app
|
25 |
|
26 |
# Start the FastAPI app on port 7860, the default port expected by Spaces
|
app.py
CHANGED
@@ -1,23 +1,11 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
-
from transformers import pipeline
|
3 |
-
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
4 |
|
5 |
# Create a new FastAPI app instance
|
6 |
app = FastAPI(docs_url="/", redoc_url="/new_redoc")
|
7 |
|
8 |
-
# Create a translation pipeline
|
9 |
-
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-small")
|
10 |
-
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-small")
|
11 |
-
|
12 |
|
13 |
# Create a POST endpoint
|
14 |
@app.get("/generate")
|
15 |
def generate(text: str):
|
16 |
"""Traduce del castellano al inglés"""
|
17 |
-
|
18 |
-
input_text = "translate Spanish to English: " + text
|
19 |
-
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
|
20 |
-
|
21 |
-
outputs = model.generate(input_ids)
|
22 |
-
print(tokenizer.decode(outputs[0]))
|
23 |
-
return {"output": tokenizer.decode(outputs[0])}
|
|
|
1 |
from fastapi import FastAPI
|
|
|
|
|
2 |
|
3 |
# Create a new FastAPI app instance
|
4 |
app = FastAPI(docs_url="/", redoc_url="/new_redoc")
|
5 |
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Create a POST endpoint
|
8 |
@app.get("/generate")
|
9 |
def generate(text: str):
|
10 |
"""Traduce del castellano al inglés"""
|
11 |
+
return {"output": text}
|
|
|
|
|
|
|
|
|
|
|
|
docker-compose.yml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: '3.8'
|
2 |
+
services:
|
3 |
+
your-service:
|
4 |
+
image: prueba-ia
|
5 |
+
ports:
|
6 |
+
- "7860:7860"
|
7 |
+
deploy:
|
8 |
+
resources:
|
9 |
+
reservations:
|
10 |
+
devices:
|
11 |
+
- driver: nvidia
|
12 |
+
count: 1
|
13 |
+
capabilities: [ gpu ]
|
requirements.txt
CHANGED
@@ -3,4 +3,4 @@ requests==2.27.*
|
|
3 |
uvicorn[standard]==0.17.*
|
4 |
sentencepiece==0.1.*
|
5 |
torch==1.11.*
|
6 |
-
transformers==4.*
|
|
|
3 |
uvicorn[standard]==0.17.*
|
4 |
sentencepiece==0.1.*
|
5 |
torch==1.11.*
|
6 |
+
#transformers==4.*
|