Santhosh Reddy
commited on
Commit
•
ceb1df4
1
Parent(s):
99286b4
added files
Browse files- Dockerfile +17 -0
- docker-compose.yml +18 -0
- entrypoint.sh +3 -0
- main.py +14 -0
- requirements.txt +34 -0
Dockerfile
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.11.2-slim
|
2 |
+
|
3 |
+
EXPOSE 8000
|
4 |
+
WORKDIR /app
|
5 |
+
|
6 |
+
|
7 |
+
RUN apt-get update && \
|
8 |
+
apt-get install -y --no-install-recommends netcat && \
|
9 |
+
apt-get -y install libpq-dev gcc && \
|
10 |
+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
11 |
+
|
12 |
+
COPY requirements.txt ./
|
13 |
+
RUN pip install -r requirements.txt
|
14 |
+
|
15 |
+
ADD . /app
|
16 |
+
|
17 |
+
ENTRYPOINT ./entrypoint.sh
|
docker-compose.yml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: '3'
|
2 |
+
|
3 |
+
services:
|
4 |
+
news_classification:
|
5 |
+
container_name: news_classification
|
6 |
+
image: news_classification:latest
|
7 |
+
build:
|
8 |
+
context: .
|
9 |
+
dockerfile: Dockerfile
|
10 |
+
restart: always
|
11 |
+
ports:
|
12 |
+
- "8000:8000"
|
13 |
+
environment:
|
14 |
+
IMAGE: "news_classification"
|
15 |
+
logging:
|
16 |
+
options:
|
17 |
+
max-file: "5"
|
18 |
+
max-size: "10m"
|
entrypoint.sh
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
uvicorn main:app --host=0.0.0.0 --reload --port 8000
|
main.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
from fastapi import FastAPI
|
3 |
+
|
4 |
+
app = FastAPI()
|
5 |
+
|
6 |
+
classifier = pipeline("zero-shot-classification", model='cross-encoder/nli-deberta-v3-base')
|
7 |
+
|
8 |
+
|
9 |
+
@app.get("/")
|
10 |
+
async def root(title):
|
11 |
+
categories = ["technology", "sports", "politics", "weather", "business", "entertainment"]
|
12 |
+
response = classifier(title, categories)
|
13 |
+
response["category"] = response["labels"][0]
|
14 |
+
return response
|
requirements.txt
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
anyio==3.6.2
|
2 |
+
certifi==2023.5.7
|
3 |
+
charset-normalizer==3.1.0
|
4 |
+
click==8.1.3
|
5 |
+
fastapi==0.95.2
|
6 |
+
filelock==3.12.0
|
7 |
+
fsspec==2023.5.0
|
8 |
+
h11==0.14.0
|
9 |
+
huggingface-hub==0.14.1
|
10 |
+
idna==3.4
|
11 |
+
Jinja2==3.1.2
|
12 |
+
MarkupSafe==2.1.2
|
13 |
+
mpmath==1.3.0
|
14 |
+
networkx==3.1
|
15 |
+
numpy==1.24.3
|
16 |
+
packaging==23.1
|
17 |
+
Pillow==9.5.0
|
18 |
+
protobuf==3.20.0
|
19 |
+
pydantic==1.10.8
|
20 |
+
PyYAML==6.0
|
21 |
+
regex==2023.5.5
|
22 |
+
requests==2.31.0
|
23 |
+
sentencepiece==0.1.99
|
24 |
+
sniffio==1.3.0
|
25 |
+
starlette==0.27.0
|
26 |
+
sympy==1.12
|
27 |
+
tokenizers==0.13.3
|
28 |
+
torch==2.0.1
|
29 |
+
torchvision==0.15.2
|
30 |
+
tqdm==4.65.0
|
31 |
+
transformers==4.29.2
|
32 |
+
typing_extensions==4.6.2
|
33 |
+
urllib3==2.0.2
|
34 |
+
uvicorn==0.22.0
|