elismasilva commited on
Commit
e8d09af
·
1 Parent(s): 4c4a1d7

adjust util.py

Browse files
Files changed (1) hide show
  1. pipeline/util.py +3 -41
pipeline/util.py CHANGED
@@ -178,46 +178,6 @@ def calculate_overlap(width, height, base_overlap=128):
178
  return base_overlap, base_overlap * 2
179
 
180
 
181
- # def calculate_overlap(width, height, base_overlap=128, scale=4):
182
- # """
183
- # Calculates dynamic overlap based on the image's aspect ratio and resolution.
184
- # For scales less than 4, the overlap is fixed at 64, 128 (or 128, 256).
185
- # For scales 4 or greater, the overlap is adjusted proportionally to the scale.
186
-
187
- # Args:
188
- # width (int): Width of the image in pixels.
189
- # height (int): Height of the image in pixels.
190
- # base_overlap (int, optional): Base overlap value in pixels. Defaults to 128.
191
- # scale (int, optional): Scale factor for calculating the overlap. Defaults to 4.
192
-
193
- # Returns:
194
- # tuple: A tuple containing:
195
- # - row_overlap (int): Overlap between tiles in consecutive rows.
196
- # - col_overlap (int): Overlap between tiles in consecutive columns.
197
- # """
198
- # # Define the base scale (4)
199
- # base_scale = 4
200
-
201
- # # If scale is less than 4, use fixed overlap values
202
- # if scale < base_scale:
203
- # ratio = height / width
204
- # if ratio < 1: # Image is wider than tall
205
- # return base_overlap // 2, base_overlap
206
- # else: # Image is taller than wide
207
- # return base_overlap, base_overlap * 2
208
- # else:
209
- # # For scales 4 or greater, adjust overlap proportionally
210
- # scaling_factor = scale / base_scale
211
- # base_overlap = int(base_overlap * base_scale)
212
- # #base_overlap = int(base_overlap * scaling_factor)
213
-
214
- # ratio = height / width
215
- # if ratio < 1: # Image is wider than tall
216
- # return base_overlap // 2, base_overlap
217
- # else: # Image is taller than wide
218
- # return base_overlap, base_overlap * 2
219
-
220
-
221
  # This function was copied and adapted from https://huggingface.co/spaces/gokaygokay/TileUpscalerV2, licensed under Apache 2.0.
222
  def progressive_upscale(input_image, target_resolution, steps=3):
223
  """
@@ -296,9 +256,11 @@ def create_hdr_effect(original_image, hdr):
296
  # Convert the HDR image to 8-bit format (0-255 range)
297
  hdr_image_8bit = np.clip(hdr_image * 255, 0, 255).astype("uint8")
298
 
 
 
299
  # Convert the image back to RGB format and return as a PIL image
300
  return Image.fromarray(cv2.cvtColor(hdr_image_8bit, cv2.COLOR_BGR2RGB))
301
-
302
 
303
  def torch_gc():
304
  if torch.cuda.is_available():
 
178
  return base_overlap, base_overlap * 2
179
 
180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  # This function was copied and adapted from https://huggingface.co/spaces/gokaygokay/TileUpscalerV2, licensed under Apache 2.0.
182
  def progressive_upscale(input_image, target_resolution, steps=3):
183
  """
 
256
  # Convert the HDR image to 8-bit format (0-255 range)
257
  hdr_image_8bit = np.clip(hdr_image * 255, 0, 255).astype("uint8")
258
 
259
+ torch_gc()
260
+
261
  # Convert the image back to RGB format and return as a PIL image
262
  return Image.fromarray(cv2.cvtColor(hdr_image_8bit, cv2.COLOR_BGR2RGB))
263
+
264
 
265
  def torch_gc():
266
  if torch.cuda.is_available():