Skip to content

Commit

Permalink
Switch to opencv-python-headless to avoid conflict.
Browse files Browse the repository at this point in the history
Also fixed bug with Path
  • Loading branch information
lovaslin committed Aug 23, 2024
1 parent 5021795 commit 0434d39
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ readme = "README.md"
license = { file="LICENSE" }
requires-python = ">=3.7"
dependencies = [
"opencv-python",
"opencv-python-headless",
"numpy",
"torch",
"scikit-learn",
Expand Down
3 changes: 2 additions & 1 deletion src/defect_detection/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import torch
from .deep_AE import AE_cls
from pathlib import Path


# Error map using mean
Expand Down Expand Up @@ -44,7 +45,7 @@ def deepAE_load(path, use_only=True, loss_fn=None, opt=None, opt_param=None):
If None, a empty dict is assumed.
"""
# Load the model hyperparameter
with open(path + "AE_config.txt") as f:
with Path.open(Path(path + "AE_config.txt")) as f:
param = eval(f.read())

# Initilize the model
Expand Down
7 changes: 4 additions & 3 deletions src/defect_detection/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import cv2 as cv
import torch
import os
from pathlib import Path
import concurrent.futures as thd


Expand Down Expand Up @@ -103,7 +104,7 @@ def generate_dataset(
"Ncore": Ncore,
"seed": seed,
}
with open(param["opath"] + param["name"] + ".txt", "w") as f:
with Path.open(Path(param["opath"] + param["name"] + ".txt"), "w") as f:
print(param, file=f)

print("Preprocessing parameters :")
Expand All @@ -112,7 +113,7 @@ def generate_dataset(

# Load initial croping if needed
if param["fcrop"] is not None:
with open(param["fcrop"]) as f:
with Path.open(Path(param["fcrop"]), "r") as f:
cr = eval(f.read())
else:
cr = None
Expand All @@ -124,7 +125,7 @@ def generate_dataset(

# Get the image list from file
fl = []
with open(param["Flist"]) as f:
with Path.open(Path(param["Flist"])) as f:
for li in f.readlines():
if li[0] == "#":
continue
Expand Down

0 comments on commit 0434d39

Please sign in to comment.