sarthaksavvy commited on
Commit
c49ad09
·
1 Parent(s): 4edcae0

[main] use hf model

Browse files
Files changed (3) hide show
  1. Dockerfile +9 -0
  2. app.py +18 -0
  3. requirements.txt +5 -0
Dockerfile ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ WORKDIR /app
4
+
5
+ COPY ./ /app
6
+
7
+ RUN pip install -r requirements.txt
8
+
9
+ CMD fastapi run --reload --host=0.0.0.0 --port=7860
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ # Use a pipeline as a high-level helper
3
+ from transformers import pipeline
4
+
5
+ pipe = pipeline("text2text-generation", model="google/flan-t5-base")
6
+
7
+ app = FastAPI()
8
+
9
+
10
+ @app.get('/')
11
+ def home():
12
+ return {"hello": "Bitfumes"}
13
+
14
+
15
+ @app.get('/ask')
16
+ def ask(prompt: str):
17
+ result = pipe(prompt)
18
+ return result[0]
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ fastapi
2
+ uvicorn
3
+ transformers
4
+ torch
5
+ torchvision