Spaces:
Runtime error
Runtime error
Upload 4 files
Browse files- Dockerfile +28 -0
- README.md +1 -11
- app.py +23 -0
- requirements.txt +6 -0
Dockerfile
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# using the offical python 3.12.1 image
|
2 |
+
from python:3.12.1
|
3 |
+
# set the working directory to / code
|
4 |
+
WORKDIR / code
|
5 |
+
#copy the current directoy contentents in container at / code
|
6 |
+
copy ./ requirements.txt/code/ requirements.txt
|
7 |
+
# install the requirements.txt
|
8 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
9 |
+
# set up a new user name "user"
|
10 |
+
RUN useradd user
|
11 |
+
|
12 |
+
USER user
|
13 |
+
# set home to home user's directory
|
14 |
+
ENV HOME=/home/user \
|
15 |
+
PATH=/home/user/.local/bin:$PATH
|
16 |
+
# Set the working directory in the container to the home directory of the new user
|
17 |
+
WORKDIR $HOME/app
|
18 |
+
|
19 |
+
# Set the working directory in the container to the home directory of the new user
|
20 |
+
WORKDIR $HOME/app
|
21 |
+
# Change the ownership of the copied files to the new user
|
22 |
+
COPY --chown=user .$HOME/app
|
23 |
+
|
24 |
+
# Start FastAPI with uvicorn
|
25 |
+
CMD ["uvicorn", "app:app", "--host" , "0.0.0.0", "--port", "7860"]
|
26 |
+
|
27 |
+
|
28 |
+
|
README.md
CHANGED
@@ -1,11 +1 @@
|
|
1 |
-
|
2 |
-
title: Text2textwithDockers
|
3 |
-
emoji: ⚡
|
4 |
-
colorFrom: purple
|
5 |
-
colorTo: green
|
6 |
-
sdk: docker
|
7 |
-
pinned: false
|
8 |
-
license: mit
|
9 |
-
---
|
10 |
-
|
11 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
# dockersgenAI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# @title Default title text
|
2 |
+
from fastapi import FastAPI
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
#create nea fastAPI app instance
|
6 |
+
app=FastAPI()
|
7 |
+
|
8 |
+
# Use a pipeline as a high-level helper
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
pipeline=pipeline("text2text-generation", model="google/flan-t5-small")
|
13 |
+
|
14 |
+
@app.get("/")
|
15 |
+
def home():
|
16 |
+
return {"messag":" hellow word"}
|
17 |
+
@app.get("/generate")
|
18 |
+
def generate(text:str):
|
19 |
+
# Initialize the text generation pipeline
|
20 |
+
|
21 |
+
output=pipe(text)
|
22 |
+
|
23 |
+
return {"output_text":output}[0]['generated_text']
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
fastapi==0.76.*
|
2 |
+
requests==2.27.*
|
3 |
+
uvicorn[standard]==0.17.*
|
4 |
+
sentencepiece==0.1.*
|
5 |
+
torch==1.11.*
|
6 |
+
transformers==4.*
|