Commit
·
d1fe2cb
1
Parent(s):
439b1dd
feat:added files
Browse files- Dockerfile +13 -0
- main.py +58 -0
- requirements.txt +4 -0
Dockerfile
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9
|
2 |
+
|
3 |
+
RUN useradd -m -u 1000 user
|
4 |
+
USER user
|
5 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
6 |
+
|
7 |
+
WORKDIR /app
|
8 |
+
|
9 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
10 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
11 |
+
|
12 |
+
COPY --chown=user . /app
|
13 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
main.py
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# from fastapi import FastAPI
|
2 |
+
# from pydantic import BaseModel
|
3 |
+
# from transformers import RobertaTokenizerFast, RobertaForSequenceClassification, TextClassificationPipeline
|
4 |
+
# import uvicorn
|
5 |
+
|
6 |
+
# # Define FastAPI app
|
7 |
+
# app = FastAPI()
|
8 |
+
|
9 |
+
# # Load Model on Startup
|
10 |
+
# HUGGINGFACE_MODEL_PATH = "bespin-global/klue-roberta-small-3i4k-intent-classification"
|
11 |
+
|
12 |
+
# print("Loading model...") # Log message
|
13 |
+
# try:
|
14 |
+
# loaded_tokenizer = RobertaTokenizerFast.from_pretrained(HUGGINGFACE_MODEL_PATH)
|
15 |
+
# loaded_model = RobertaForSequenceClassification.from_pretrained(HUGGINGFACE_MODEL_PATH)
|
16 |
+
|
17 |
+
# # Create Text Classification Pipeline
|
18 |
+
# text_classifier = TextClassificationPipeline(
|
19 |
+
# tokenizer=loaded_tokenizer,
|
20 |
+
# model=loaded_model,
|
21 |
+
# return_all_scores=True
|
22 |
+
# )
|
23 |
+
# print("Model loaded successfully.") # Log message
|
24 |
+
# except Exception as e:
|
25 |
+
# print(f"Error loading model: {e}")
|
26 |
+
# text_classifier = None
|
27 |
+
|
28 |
+
|
29 |
+
# # Define Request Model
|
30 |
+
# class PredictionRequest(BaseModel):
|
31 |
+
# text: str
|
32 |
+
|
33 |
+
# @app.get("/")
|
34 |
+
# def home(request):
|
35 |
+
# return {"message":"Running fine"}
|
36 |
+
# # Prediction Endpoint
|
37 |
+
# @app.post("/predict")
|
38 |
+
# def predict_intent(request: PredictionRequest):
|
39 |
+
# if text_classifier is None:
|
40 |
+
# return {"error": "Model not found"}
|
41 |
+
# preds_list = text_classifier(request.text)
|
42 |
+
# best_pred = max(preds_list[0], key=lambda x: x["score"]) # Get highest-scoring intent
|
43 |
+
# return {"intent": best_pred["label"], "confidence": best_pred["score"]}
|
44 |
+
|
45 |
+
|
46 |
+
# # Launch FastAPI with Uvicorn
|
47 |
+
# if __name__ == "__main__":
|
48 |
+
# uvicorn.run(app, host="0.0.0.0", port=8000, workers=1)
|
49 |
+
|
50 |
+
|
51 |
+
from fastapi import FastAPI
|
52 |
+
|
53 |
+
app=FastAPI()
|
54 |
+
|
55 |
+
@app.get("/")
|
56 |
+
def hello():
|
57 |
+
return {"hello":"success"}
|
58 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
fastapi
|
2 |
+
uvicorn
|
3 |
+
transformers
|
4 |
+
torch
|