Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- Dockerfile +0 -0
- app.py +23 -0
- requirements.txt +6 -0
Dockerfile
ADDED
File without changes
|
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
|
5 |
+
# Creating a new FASTAPI app instance
|
6 |
+
app = FastAPI()
|
7 |
+
|
8 |
+
# Initialize the text generation pipeline
|
9 |
+
pipe= pipeline()
|
10 |
+
# Use a pipeline as a high-level helper
|
11 |
+
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
|
12 |
+
|
13 |
+
@app.get("/")
|
14 |
+
def home():
|
15 |
+
return{"message":"Hello World"}
|
16 |
+
|
17 |
+
# Defining the function to handle the get req.
|
18 |
+
@ app.get("/generate")
|
19 |
+
def generate_text(inp:str):
|
20 |
+
#Pipeline to generate text from given input text
|
21 |
+
output = pipe(text)
|
22 |
+
#Return the generated text in Json response
|
23 |
+
return{"output":output[0]['generated_text']}
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
fastapi==0.74.*
|
2 |
+
requests==2.27.*
|
3 |
+
uvicorn[standard]==0.17.*
|
4 |
+
sentencepiece==0.1.*
|
5 |
+
torch
|
6 |
+
transformers==4.*
|