Kryko7 commited on
Commit
aca7985
1 Parent(s): 4427fab

Implemented all the necessary files

Files changed (3) hide show
  1. Dockerfile +12 -0
  2. app.py +14 -0
  3. requirements.txt +6 -0
Dockerfile ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ WORKDIR /code
4
+
5
+ COPY ./requirements.txt /code/requirements.txt
6
+
7
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
+
9
+ COPY . .
10
+
11
+ CMD ["unicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
12
+
app.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from transformers import pipeline
3
+
4
+ app = FastAPI()
5
+
6
+
7
+ pipe = pipeline("text-generation", model="google/flan-t5-small")
8
+
9
+
10
+ @app.get("/generate")
11
+ def generate(query: str):
12
+ output = pipe(query, max_length=50, do_sample=True, top_k=50)
13
+ return {"output": output[0]["generated_text"], "query": query, "model": "google/flan-t5-small"}
14
+
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ fastapi==0.74.*
2
+ requests==2.27.*
3
+ uvicorn==0.17.*
4
+ sentencepiece==0.01.*
5
+ torch==1.11.*
6
+ transformers==4.*