meepmoo commited on
Commit
1471bad
·
verified ·
1 Parent(s): 019f0d9

Update worker_runpod.py

Browse files
Files changed (1) hide show
  1. worker_runpod.py +13 -1
worker_runpod.py CHANGED
@@ -17,13 +17,25 @@ from cogvideox.models.autoencoder_magvit import AutoencoderKLCogVideoX
17
  from cogvideox.pipeline.pipeline_cogvideox import CogVideoX_Fun_Pipeline
18
  from cogvideox.pipeline.pipeline_cogvideox_inpaint import CogVideoX_Fun_Pipeline_Inpaint
19
  from cogvideox.utils.lora_utils import merge_lora, unmerge_lora
20
- from cogvideox.utils.utils import get_image_to_video_latent, save_videos_grid, ASPECT_RATIO_512, get_closest_ratio, to_pil
 
21
  from huggingface_hub import HfApi, HfFolder
22
 
23
  tokenxf = os.getenv("HF_API_TOKEN")
24
  # Low GPU memory mode
25
  low_gpu_memory_mode = False
26
  lora_path = "/content/shirtlift.safetensors"
 
 
 
 
 
 
 
 
 
 
 
27
  def download_image(url, download_dir="asset"):
28
  # Ensure the download directory exists
29
  if not os.path.exists(download_dir):
 
17
  from cogvideox.pipeline.pipeline_cogvideox import CogVideoX_Fun_Pipeline
18
  from cogvideox.pipeline.pipeline_cogvideox_inpaint import CogVideoX_Fun_Pipeline_Inpaint
19
  from cogvideox.utils.lora_utils import merge_lora, unmerge_lora
20
+ from cogvideox.utils.utils import get_image_to_video_latent, save_videos_grid
21
+ from cogvideox.data.bucket_sampler import ASPECT_RATIO_512, get_closest_ratio
22
  from huggingface_hub import HfApi, HfFolder
23
 
24
  tokenxf = os.getenv("HF_API_TOKEN")
25
  # Low GPU memory mode
26
  low_gpu_memory_mode = False
27
  lora_path = "/content/shirtlift.safetensors"
28
+
29
+ def to_pil(image):
30
+ if isinstance(image, Image.Image):
31
+ return image
32
+ if isinstance(image, torch.Tensor):
33
+ return tensor2pil(image)
34
+ if isinstance(image, np.ndarray):
35
+ return numpy2pil(image)
36
+ raise ValueError(f"Cannot convert {type(image)} to PIL.Image")
37
+
38
+
39
  def download_image(url, download_dir="asset"):
40
  # Ensure the download directory exists
41
  if not os.path.exists(download_dir):