Skip to content

Conversation

@Anas2312123
Copy link
Collaborator

No description provided.

@Anas2312123 Anas2312123 requested a review from bojeanson July 10, 2025 15:38
@Anas2312123 Anas2312123 self-assigned this Jul 10, 2025

EXPOSE 8000

CMD ["sh", "-c", "PYTHONPATH=/app/src uvicorn onnx_server:app --reload --host 0.0.0.0 --port 8000"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CMD ["sh", "-c", "PYTHONPATH=/app/src uvicorn onnx_server:app --reload --host 0.0.0.0 --port 8000"]
ENV PYTHONPATH=/app/src
ENTRYPOINT ["uvicorn"]
CMD ["onnx_server:app", "--reload", "--host", "0.0.0.0", "--port", "8000"]

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tu peux virer ce fichier si on a un pyproject.toml

Comment on lines 1 to 21

import logging
from typing import Any, AnyStr, Dict, List, Union
import numpy as np
from fastapi import APIRouter, HTTPException, Request
import onnxruntime as ort
import time
import os
from PIL import Image
from pathlib import Path





from utils.yolo11n_postprocessing import (
compute_severities,
non_max_suppression,
yolo_extract_boxes_information,
compute_iou,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exécute le linter pour respecter la pep8 stp


# Lister les modèles ONNX chargés
@api_router.get("/models")
async def get_models(request: Request):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tu peux ajouter du type hint pour le retour stp


# Récupérer les métadonnées d’un modèle
@api_router.get("/models/{model_name}/versions/{model_version}/resolution")
async def get_model_metadata(model_name: str, model_version: str, request: Request):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pareil le type hint de retour stp





Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

faudrait que tu appliques un linter pour éviter toutes ces lignes inutiles -> regarde là

os.environ["MODELS_PATH"] = "../models"

# sys.path.append() ajoute src/ aux chemins où Python cherche les modules.
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../src")))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pourquoi on a besoin de faire ça ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ligne 11 : Car ce code configure une variable d'environnement qui indique où trouver les modèles ONNX
Le serveur utilise cette variable pour savoir où chercher les modèles à charger

ligne 14 : car elle ajoute le dossier src au PYTHONPATH, c'est nécessaire car le fichier de test est dans le dossier tests et a besoin d'importer des modules du dossier src.
Sans cette ligne, Python ne pourrait pas trouver le module onnx_server car il n'est pas dans le chemin de recherche par défaut. C'est pourquoi cet ajout doit être fait avant l'import from onnx_server import app



# Créer un client de test
client = TestClient(app)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

à mettre dans une fixture aussi stp

Comment on lines 31 to 36
def test_homepage(self):
"""Test de la page d'accueil"""
response = client.get("/")
assert response.status_code == 200
assert "Welcome to the onnx-server" in response.text

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pour les tests tu peux respecter la structure suivante stp :

  • # Given
  • # When
  • # Then

Comment on lines 61 to 65
image = Image.open(image_path).convert("RGB")
image = image.resize((640, 640))
image_array = np.array(image).astype(np.float32) / 255.0
image_array = np.transpose(image_array, (2, 0, 1))
image_array = np.expand_dims(image_array, axis=0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pourquoi a-t-on besoin de faire tout ça ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Car ces traitement sur l'image sont nécessaires pour la préparer au format attendu par le modèle YOLO, sinon le modèle ne pourra pas lire l'image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants