Spaces:
Runtime error
Runtime error
fix
Browse files
app.py
CHANGED
@@ -68,20 +68,19 @@ def random_positioning(input, output_size=(1024, 1024)):
|
|
68 |
|
69 |
background = cv2.resize(background, output_size, interpolation=cv2.INTER_AREA)
|
70 |
|
71 |
-
if
|
72 |
raise ValueError("Unable to load input image")
|
73 |
|
74 |
scale_factor = random.uniform(0.5, 1.0)
|
75 |
-
new_size = (int(
|
76 |
|
77 |
-
resized_image = cv2.resize(
|
78 |
|
79 |
if background.shape[2] != resized_image.shape[2]:
|
80 |
raise ValueError("Input image and background image must have the same number of channels")
|
81 |
|
82 |
x_offset = random.randint(0, output_size[0] - new_size[0])
|
83 |
y_offset = random.randint(0, output_size[1] - new_size[1])
|
84 |
-
# Sobrepor a imagem redimensionada na imagem de fundo
|
85 |
background[y_offset:y_offset+new_size[1], x_offset:x_offset+new_size[0]] = resized_image
|
86 |
|
87 |
return background
|
|
|
68 |
|
69 |
background = cv2.resize(background, output_size, interpolation=cv2.INTER_AREA)
|
70 |
|
71 |
+
if input is None:
|
72 |
raise ValueError("Unable to load input image")
|
73 |
|
74 |
scale_factor = random.uniform(0.5, 1.0)
|
75 |
+
new_size = (int(input.shape[1] * scale_factor), int(input.shape[0] * scale_factor))
|
76 |
|
77 |
+
resized_image = cv2.resize(input, new_size, interpolation=cv2.INTER_AREA)
|
78 |
|
79 |
if background.shape[2] != resized_image.shape[2]:
|
80 |
raise ValueError("Input image and background image must have the same number of channels")
|
81 |
|
82 |
x_offset = random.randint(0, output_size[0] - new_size[0])
|
83 |
y_offset = random.randint(0, output_size[1] - new_size[1])
|
|
|
84 |
background[y_offset:y_offset+new_size[1], x_offset:x_offset+new_size[0]] = resized_image
|
85 |
|
86 |
return background
|