PrashanthB461 commited on
Commit
0660ef9
·
verified ·
1 Parent(s): a0fae2a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import os
2
 
3
  # Set YOLO_CONFIG_DIR before any Ultralytics imports
4
- os.environ["YOLO_CONFIG_DIR"] = "/tmp"
5
 
6
  from fastapi import FastAPI, File, UploadFile, HTTPException
7
  from contextlib import asynccontextmanager
@@ -21,6 +21,9 @@ import pandas as pd
21
  logging.basicConfig(level=logging.INFO)
22
  logger = logging.getLogger(__name__)
23
 
 
 
 
24
  # Log environment variable for debugging
25
  logger.info(f"YOLO_CONFIG_DIR set to: {os.getenv('YOLO_CONFIG_DIR')}")
26
 
@@ -57,6 +60,7 @@ app = FastAPI(lifespan=lifespan)
57
  class YOLOv8Model:
58
  def __init__(self, model_path='yolov8n.pt'):
59
  try:
 
60
  self.model = YOLO(model_path) # Load YOLOv8 model
61
  logger.info("YOLOv8 model loaded successfully")
62
  except Exception as e:
 
1
  import os
2
 
3
  # Set YOLO_CONFIG_DIR before any Ultralytics imports
4
+ os.environ["YOLO_CONFIG_DIR"] = "/tmp/Ultralytics"
5
 
6
  from fastapi import FastAPI, File, UploadFile, HTTPException
7
  from contextlib import asynccontextmanager
 
21
  logging.basicConfig(level=logging.INFO)
22
  logger = logging.getLogger(__name__)
23
 
24
+ # Suppress Ultralytics logging to reduce redundant messages
25
+ logging.getLogger("ultralytics").setLevel(logging.WARNING)
26
+
27
  # Log environment variable for debugging
28
  logger.info(f"YOLO_CONFIG_DIR set to: {os.getenv('YOLO_CONFIG_DIR')}")
29
 
 
60
  class YOLOv8Model:
61
  def __init__(self, model_path='yolov8n.pt'):
62
  try:
63
+ logger.info("Initializing YOLOv8 model")
64
  self.model = YOLO(model_path) # Load YOLOv8 model
65
  logger.info("YOLOv8 model loaded successfully")
66
  except Exception as e: