Open justfouw opened 5 years ago
'''
Process the 0-th class, containing 447 elements...............Traceback (most recent call last):
File "decor_recomposition.py", line 609, in
Hi. I have similar error with opencv. Please share the version that you are using.
@justfouw Hi, any luck with this problem?
@bado-lee It is not an issue of the opencv version. The h,w
passed to function resize()
is 0. Thus, some boundary protection operations will be useful. such as
...
h = max(h, 1)
w = max(w, 1)
...
@justfouw Thank you for your comment. I'll try your suggestion.
weird it's holding there... @justfouw Were you successful running the "runtest.py" ?
@justfouw it seems like it falls into infinite loop. after applying protective operation...
decor_recomposition.py : while(x_start<5 or y_start<5 or x_end>output_img.shape[0]-5 or y_end>output_img.shape[1]-5):
I was able to run runtest.py after a bit of modification. Simply check new_size validity before resizing. If it's not valid, continue. Hope this will help someone. Anyhow, my test result with custom data was not as good as expected. It finds basal patterns as decor.
# git diff decor_recomposition.py
diff --git a/decor_recomposition.py b/decor_recomposition.py
index 1793b4b..8baa998 100644
--- a/decor_recomposition.py
+++ b/decor_recomposition.py
@@ -400,6 +400,10 @@ class GetObjectTool():
new_size_ratio = (elements_num_ratio * (0.75+random.random()/2)) ** 0.2
new_size_x = int(mask.shape[0] * new_size_ratio)
new_size_y = int(mask.shape[1] * new_size_ratio)
+
+ if new_size_x < 1 or new_size_y < 1:
+ continue
+
mask = mask / 255.
mask = cv2.resize(mask,(new_size_x,new_size_y))
deco = decorationClass[cur_num]['Object']
@@ -433,6 +437,9 @@ class GetObjectTool():
new_size_x = int(new_size_x * reshape_ratio)
new_size_y = int(new_size_y * reshape_ratio)
+ if new_size_x < 1 or new_size_y < 1:
+ continue
+
deco = cv2.resize(deco,(new_size_y,new_size_x))
mask = cv2.resize(mask,(new_size_y,new_size_x))
@@ -449,6 +456,10 @@ class GetObjectTool():
new_size_x = int(new_size_x * 0.95)
new_size_y = int(new_size_y * 0.95)
+ if new_size_x < 1 or new_size_y < 1:
+ beyoung_boundary = True
+ break
+
deco = cv2.resize(deco,(new_size_y,new_size_x))
mask = cv2.resize(mask,(new_size_y,new_size_x))
Hi, bado-lee, even though I modified the code as you adviced, the following issue occured:
Traceback (most recent call last):
File "decor_recomposition.py", line 616, in
@xphsean12 I didn't face the same issue. However, the error is because of dimension mismatch between "input_thinkness_map" and the "mask" I think this is the error that should be debugged. Anyways, you can bypass the situation by adding
if input_thickness_map.shape != mask.shape:
continue
just before line 418. but no guarantee. you can try... :)
@bado-lee
Thanks! It hepls.
I run
python runtest.py
. The style-content pair isface-lan
. The error is on cv2.resize(), It seems that this input image has an invalid shape.In addition, Could you provide the specified version of workspace, such as the version of pytorch, opencv, etc.