Atef-le-viking commited on
Commit
24dff96
·
1 Parent(s): 0f5acda

Modèle yolo11x + imgsz 1280 + conf 0.25 (recall petits objets / personnes à l'eau pour SAR)

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -1
  2. main.py +3 -3
Dockerfile CHANGED
@@ -6,6 +6,6 @@ COPY requirements.txt .
6
  RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cu121
7
  RUN pip install --no-cache-dir -r requirements.txt
8
  COPY . .
9
- RUN python -c "from ultralytics import YOLO; YOLO('yolov8s.pt')"
10
  EXPOSE 7860
11
  CMD ["uvicorn","main:app","--host","0.0.0.0","--port","7860"]
 
6
  RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cu121
7
  RUN pip install --no-cache-dir -r requirements.txt
8
  COPY . .
9
+ RUN python -c "from ultralytics import YOLO; YOLO('yolo11x.pt')"
10
  EXPOSE 7860
11
  CMD ["uvicorn","main:app","--host","0.0.0.0","--port","7860"]
main.py CHANGED
@@ -9,7 +9,7 @@ from ultralytics import YOLO
9
  app = FastAPI()
10
  app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"])
11
  DEV = 0 if torch.cuda.is_available() else "cpu"
12
- model = YOLO("yolov8s.pt")
13
  KEEP = {"boat": "SHIP", "person": "HUMAN"}
14
  try:
15
  model.predict(Image.new("RGB", (640, 384)), device=DEV, verbose=False) # warmup
@@ -18,14 +18,14 @@ except Exception:
18
 
19
  @app.get("/")
20
  def root():
21
- return {"ok": True, "model": "yolov8s", "device": str(DEV), "cuda": torch.cuda.is_available()}
22
 
23
  @app.post("/detect")
24
  async def detect(req: Request):
25
  data = await req.body()
26
  img = Image.open(io.BytesIO(data)).convert("RGB")
27
  W, H = img.size
28
- r = model.predict(img, conf=0.35, imgsz=640, device=DEV, verbose=False)[0]
29
  dets = []
30
  for b in r.boxes:
31
  c = model.names[int(b.cls)]
 
9
  app = FastAPI()
10
  app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"])
11
  DEV = 0 if torch.cuda.is_available() else "cpu"
12
+ model = YOLO("yolo11x.pt")
13
  KEEP = {"boat": "SHIP", "person": "HUMAN"}
14
  try:
15
  model.predict(Image.new("RGB", (640, 384)), device=DEV, verbose=False) # warmup
 
18
 
19
  @app.get("/")
20
  def root():
21
+ return {"ok": True, "model": "yolo11x", "imgsz": 1280, "conf": 0.25, "device": str(DEV), "cuda": torch.cuda.is_available()}
22
 
23
  @app.post("/detect")
24
  async def detect(req: Request):
25
  data = await req.body()
26
  img = Image.open(io.BytesIO(data)).convert("RGB")
27
  W, H = img.size
28
+ r = model.predict(img, conf=0.25, imgsz=1280, device=DEV, verbose=False)[0]
29
  dets = []
30
  for b in r.boxes:
31
  c = model.names[int(b.cls)]