patrickvonplaten commited on
Commit
22b5903
·
1 Parent(s): 7f2323b
Files changed (2) hide show
  1. _ +0 -35
  2. ~ +0 -51
_ DELETED
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env python3
2
- import torch
3
- from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
4
- import numpy as np
5
- import gc
6
- from diffusers.utils import export_to_video
7
- from PIL import Image
8
-
9
- pipe = DiffusionPipeline.from_pretrained("cerspense/zeroscope_v2_576w", torch_dtype=torch.float16)
10
- pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
11
- pipe.enable_model_cpu_offload()
12
- pipe.enable_xformers_memory_efficient_attention()
13
- pipe.enable_vae_slicing()
14
-
15
- prompt = "spiderman running in the desert"
16
- video_frames = pipe(prompt, num_inference_steps=2, height=320, width=576, num_frames=24, output_type="latent".frames
17
- # video_path = export_to_video(video_frames, output_video_path="/home/patrick/videos/video_576_spiderman_24.mp4")
18
-
19
- pipe.to("cpu")
20
- del pipe
21
- gc.collect()
22
- torch.cuda.empty_cache()
23
-
24
- import ipdb; ipdb.set_trace()
25
-
26
- pipe = DiffusionPipeline.from_pretrained("cerspense/zeroscope_v2_XL", torch_dtype=torch.float16)
27
- pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
28
- pipe.enable_model_cpu_offload()
29
- pipe.enable_xformers_memory_efficient_attention()
30
- pipe.enable_vae_slicing()
31
-
32
- video = [Image.fromarray(frame).resize((1024, 576)) for frame in video_frames]
33
-
34
- video_frames = pipe(prompt, video=video, num_inference_steps=2, strength=0.6).frames
35
- video_path = export_to_video(video_frames, output_video_path="/home/patrick/videos/video_1024_spiderman_24.mp4")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
~ DELETED
@@ -1,51 +0,0 @@
1
- #!/usr/bin/env python3
2
- from diffusers import DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionPipeline, KDPM2DiscreteScheduler, StableDiffusionImg2ImgPipeline, HeunDiscreteScheduler, KDPM2AncestralDiscreteScheduler, DDIMScheduler, StableDiffusionXLImg2ImgPipeline
3
- import time
4
- import numpy as np
5
- import os
6
- from huggingface_hub import HfApi
7
- # from compel import Compel
8
- import torch
9
- import sys
10
- from pathlib import Path
11
- import requests
12
- from PIL import Image
13
- from io import BytesIO
14
-
15
- path = sys.argv[1]
16
-
17
- api = HfApi()
18
- start_time = time.time()
19
- pipe = StableDiffusionXLImg2ImgPipeline.from_pretrained(path)
20
- pipe.to("cuda")
21
- pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config)
22
- # pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config)
23
- # pipe = StableDiffusionImg2ImgXLPipeline.from_pretrained(path, torch_dtype=torch.float16, safety_checker=None
24
-
25
- # compel = Compel(tokenizer=pipe.tokenizer, text_encoder=pipe.text_encoder)
26
-
27
-
28
- prompt = "An astronaut riding a green horse on Mars"
29
-
30
-
31
- # pipe.unet.to(memory_format=torch.channels_last)
32
- # pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
33
- # pipe(prompt=prompt, num_inference_steps=2).images[0]
34
- # url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"
35
- #
36
- # response = requests.get(url)
37
- init_image = torch.from_numpy(np.load("/home/patrick/images/xl_latents.npy")).to("cuda")
38
-
39
- image = pipe(prompt=prompt, image=init_image).images[0]
40
-
41
- file_name = f"aaa"
42
- path = os.path.join(Path.home(), "images", f"{file_name}.png")
43
- image.save(path)
44
-
45
- api.upload_file(
46
- path_or_fileobj=path,
47
- path_in_repo=path.split("/")[-1],
48
- repo_id="patrickvonplaten/images",
49
- repo_type="dataset",
50
- )
51
- print(f"https://huggingface.co/datasets/patrickvonplaten/images/blob/main/{file_name}.png")