import os from PIL import Image import requests from io import BytesIO set path to input…
- User
import os from PIL import Image import requests from io import BytesIO
set path to input and output folders
input_folder_path = "/content/drive/MyDrive/castle" output_folder_path = "/content/drive/MyDrive/castle/processed"
loop through each image in the input folder
for filename in os.listdir(input_folder_path): if filename.endswith(('jpeg', 'png', 'jpg',"PNG","JPEG","JPG")): file_path = os.path.join(input_folder_path, filename)
load the image and get predictions
with open(file_path, "rb") as f: image_bytes = BytesIO(f.read()) input_img, height, width, height_even, width_even = pre_process(image_bytes) preds = predict(input_img) result = post_process(preds, height, width, height_even, width_even)
save the processed image to the output folder
output_file_path = os.path.join(output_folder_path, filename) im = Image.fromarray(result) im.save(output_file_path)--------------------------------------------------------------------------- ValueError Traceback (most recent call last) in <cell line: 19>() 17 image_bytes = BytesIO(f.read()) 18 input_img, height, width, height_even, width_even = pre_process(image_bytes) ---> 19 preds = predict(input_img) 20 result = post_process(preds, height, width, height_even, width_even) 21
7 frames in predict(input_img) 301 def predict(input_img): 302 # handle multi-stage outputs, obtain the last scale output of last stage --> 303 return model.apply({'params': flax.core.freeze(params)}, input_img) 304 305
[... skipping hidden 6 frame]/content/maxim/maxim/models/maxim.py in call(self, x, train) 833 834 # Decoder block --> 835 x = UNetDecoderBlock( 836 features=(2**i) * self.features, 837 num_groups=self.num_groups,
[... skipping hidden 2 frame]/content/maxim/maxim/models/maxim.py in call(self, x, bridge, deterministic) 428 x = ConvT_up(self.features, use_bias=self.use_bias)(x) 429 --> 430 x = UNetEncoderBlock( 431 self.features, 432 num_groups=self.num_groups,
[... skipping hidden 2 frame]/content/maxim/maxim/models/maxim.py in call(self, x, skip, enc, dec, deterministic) 370 for i in range(self.num_groups): 371 if self.use_global_mlp: --> 372 x = ResidualSplitHeadMultiAxisGmlpLayer( 373 grid_size=self.grid_size, 374 block_size=self.block_size,
[... skipping hidden 2 frame]/content/maxim/maxim/models/maxim.py in call(self, x, deterministic) 244 u, v = jnp.split(x, 2, axis=-1) 245 # GridGMLPLayer --> 246 u = GridGmlpLayer( 247 grid_size=self.grid_size, 248 factor=self.grid_gmlp_factor,
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.