YiYiXu commited on
Commit
d2be1f2
·
verified ·
1 Parent(s): 829f347

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +16 -1
README.md CHANGED
@@ -12,4 +12,19 @@ image = image_processor(
12
  )
13
  ```
14
 
15
- for wan 2.2 5B, the default method is here https://huggingface.co/YiYiXu/WanImageProcessor
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  )
13
  ```
14
 
15
+ for wan 2.2 5B, the default method is here https://huggingface.co/YiYiXu/WanImageProcessor
16
+
17
+ this is the code to resize
18
+
19
+ ```py
20
+
21
+ image = load_image(
22
+ "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg"
23
+ )
24
+ max_area = 720 * 1280
25
+ aspect_ratio = image.height / image.width
26
+ mod_value = pipe.vae_scale_factor_spatial * pipe.transformer.config.patch_size[1]
27
+ height = round(np.sqrt(max_area * aspect_ratio)) // mod_value * mod_value
28
+ width = round(np.sqrt(max_area / aspect_ratio)) // mod_value * mod_value
29
+ image = image.resize((width, height))
30
+ ```