jebin2 commited on
Commit
8c3ad14
·
1 Parent(s): c5942cc

path issue fix

Browse files
comic_panel_extractor/annorator_server.py CHANGED
@@ -34,7 +34,6 @@ async def websocket_endpoint(websocket: WebSocket):
34
  manager.disconnect(websocket)
35
 
36
  # === Configuration ===
37
- IMAGE_ROOT = os.path.join(Config.current_path, "images")
38
  IMAGE_LABEL_ROOT = os.path.join(Config.current_path, "image_labels")
39
 
40
  CLASS_ID = 0
@@ -78,7 +77,7 @@ class ImageInfo(BaseModel):
78
 
79
  # === Helpers ===
80
  def get_image_path(image_name: str) -> str:
81
- return os.path.join(IMAGE_ROOT, image_name)
82
 
83
  def get_label_path(image_name: str) -> str:
84
  return os.path.join(IMAGE_LABEL_ROOT, os.path.splitext(image_name)[0] + ".txt")
@@ -266,12 +265,12 @@ def parse_yolo_line(line: str, image_width: int, image_height: int) -> Dict[str,
266
  @app.get("/api/annotate/images", response_model=List[ImageInfo])
267
  async def list_all_images():
268
  image_info_list = []
269
- for root, _, files in os.walk(IMAGE_ROOT):
270
  for file in sorted(files):
271
  if file.lower().endswith((".jpg", ".jpeg", ".png")):
272
  try:
273
  image_path = os.path.join(root, file)
274
- rel_path = os.path.relpath(image_path, IMAGE_ROOT)
275
  label_path = get_label_path(rel_path)
276
 
277
  img = Image.open(image_path)
 
34
  manager.disconnect(websocket)
35
 
36
  # === Configuration ===
 
37
  IMAGE_LABEL_ROOT = os.path.join(Config.current_path, "image_labels")
38
 
39
  CLASS_ID = 0
 
77
 
78
  # === Helpers ===
79
  def get_image_path(image_name: str) -> str:
80
+ return os.path.join(Config.IMAGE_SOURCE_PATH, image_name)
81
 
82
  def get_label_path(image_name: str) -> str:
83
  return os.path.join(IMAGE_LABEL_ROOT, os.path.splitext(image_name)[0] + ".txt")
 
265
  @app.get("/api/annotate/images", response_model=List[ImageInfo])
266
  async def list_all_images():
267
  image_info_list = []
268
+ for root, _, files in os.walk(Config.IMAGE_SOURCE_PATH):
269
  for file in sorted(files):
270
  if file.lower().endswith((".jpg", ".jpeg", ".png")):
271
  try:
272
  image_path = os.path.join(root, file)
273
+ rel_path = os.path.relpath(image_path, Config.IMAGE_SOURCE_PATH)
274
  label_path = get_label_path(rel_path)
275
 
276
  img = Image.open(image_path)