aditya0929 commited on
Commit
a83d16c
·
1 Parent(s): ac4543e

Initial commit for garbage redressal space

Browse files
Files changed (5) hide show
  1. Dockerfile +17 -0
  2. app/best.onnx +3 -0
  3. app/best.pt +3 -0
  4. app/main.py +23 -0
  5. app/requirements.txt +4 -0
Dockerfile ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ # Set working directory
4
+ WORKDIR /app
5
+
6
+ # Install OS dependencies
7
+ RUN apt-get update && apt-get install -y git ffmpeg libsm6 libxext6 && rm -rf /var/lib/apt/lists/*
8
+
9
+ # Copy files
10
+ COPY app ./app
11
+ COPY app/requirements.txt .
12
+
13
+ # Install Python dependencies
14
+ RUN pip install --upgrade pip && pip install -r requirements.txt
15
+
16
+ # Set the entrypoint
17
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
app/best.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ded3505afed80de17af3563504de454bf443d1ce8a900cf1558ec6fa65ae6edc
3
+ size 10583512
app/best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:566907aca17896249bb46498098c6b5c7002403db19cd199dd1175fc7ccffcd8
3
+ size 5466259
app/main.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, UploadFile, File
2
+ from ultralytics import YOLO
3
+ import uvicorn
4
+ from PIL import Image
5
+ import io
6
+
7
+ app = FastAPI()
8
+ model = YOLO("app/model.pt") # Load the trained YOLOv11/12 model
9
+
10
+ @app.get("/")
11
+ def read_root():
12
+ return {"message": "Welcome to the Garbage Detection API"}
13
+
14
+ @app.post("/predict/")
15
+ async def predict(file: UploadFile = File(...)):
16
+ image_bytes = await file.read()
17
+ image = Image.open(io.BytesIO(image_bytes)).convert("RGB")
18
+
19
+ results = model(image)
20
+ boxes = results[0].boxes.xyxy.tolist() # List of [x1, y1, x2, y2]
21
+ confidences = results[0].boxes.conf.tolist()
22
+
23
+ return {"boxes": boxes, "confidences": confidences}
app/requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ fastapi
2
+ uvicorn
3
+ pillow
4
+ ultralytics