multimodalart HF Staff commited on
Commit
650fb2e
·
verified ·
1 Parent(s): 845427f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -5,21 +5,21 @@ from diffusers import Cosmos2TextToImagePipeline, EDMEulerScheduler
5
  import random
6
 
7
  model_14b_id = "nvidia/Cosmos-Predict2-14B-Text2Image"
8
- # model_2b_id = "nvidia/Cosmos-Predict2-2B-Text2Image"
9
 
10
  pipe_14b = Cosmos2TextToImagePipeline.from_pretrained(model_14b_id,
11
  revision="refs/pr/1",
12
  torch_dtype=torch.bfloat16
13
  )
14
  pipe_14b.to("cuda")
15
- #pipe_2b = Cosmos2TextToImagePipeline.from_pretrained(model_2b_id,
16
- # revision="refs/pr/2",
17
- # text_encoder=pipe_14b.text_encoder,
18
- # safety_checker=pipe_14b.safety_checker,
19
- # vae=pipe_14b.vae,
20
- # tokenizer=pipe_14b.tokenizer,
21
- # torch_dtype=torch.bfloat16
22
- # )
23
 
24
  scheduler = EDMEulerScheduler(
25
  sigma_min=0.002,
@@ -39,11 +39,11 @@ pipe_14b.scheduler = scheduler
39
  @spaces.GPU
40
  def generate_image(prompt, negative_prompt="The video captures a series of frames showing ugly scenes, static with no motion, motion blur, over-saturation, shaky footage, low resolution, grainy texture, pixelated images, poorly lit areas, underexposed and overexposed scenes, poor color balance, washed out colors, choppy sequences, jerky movements, low frame rate, artifacting, color banding, unnatural transitions, outdated special effects, fake elements, unconvincing visuals, poorly edited content, jump cuts, visual noise, and flickering. Overall, the video is of poor quality.", seed=42, randomize_seed=False, model_choice="14B", progress=gr.Progress(track_tqdm=True)):
41
 
42
- #if model_choice == "14B":
43
- # pipe = pipe_14b
44
- #else:
45
- # pipe = pipe_2b
46
- # pipe.to("cuda")
47
 
48
  if randomize_seed:
49
  actual_seed = random.randint(0, 1000000)
@@ -52,7 +52,7 @@ def generate_image(prompt, negative_prompt="The video captures a series of frame
52
 
53
  generator = torch.Generator().manual_seed(actual_seed)
54
 
55
- output = pipe_14b(
56
  prompt=prompt,
57
  negative_prompt=negative_prompt,
58
  generator=generator
 
5
  import random
6
 
7
  model_14b_id = "nvidia/Cosmos-Predict2-14B-Text2Image"
8
+ model_2b_id = "nvidia/Cosmos-Predict2-2B-Text2Image"
9
 
10
  pipe_14b = Cosmos2TextToImagePipeline.from_pretrained(model_14b_id,
11
  revision="refs/pr/1",
12
  torch_dtype=torch.bfloat16
13
  )
14
  pipe_14b.to("cuda")
15
+ pipe_2b = Cosmos2TextToImagePipeline.from_pretrained(model_2b_id,
16
+ revision="refs/pr/2",
17
+ text_encoder=pipe_14b.text_encoder,
18
+ safety_checker=pipe_14b.safety_checker,
19
+ vae=pipe_14b.vae,
20
+ tokenizer=pipe_14b.tokenizer,
21
+ torch_dtype=torch.bfloat16
22
+ )
23
 
24
  scheduler = EDMEulerScheduler(
25
  sigma_min=0.002,
 
39
  @spaces.GPU
40
  def generate_image(prompt, negative_prompt="The video captures a series of frames showing ugly scenes, static with no motion, motion blur, over-saturation, shaky footage, low resolution, grainy texture, pixelated images, poorly lit areas, underexposed and overexposed scenes, poor color balance, washed out colors, choppy sequences, jerky movements, low frame rate, artifacting, color banding, unnatural transitions, outdated special effects, fake elements, unconvincing visuals, poorly edited content, jump cuts, visual noise, and flickering. Overall, the video is of poor quality.", seed=42, randomize_seed=False, model_choice="14B", progress=gr.Progress(track_tqdm=True)):
41
 
42
+ if model_choice == "14B":
43
+ pipe = pipe_14b
44
+ else:
45
+ pipe = pipe_2b
46
+ pipe.to("cuda")
47
 
48
  if randomize_seed:
49
  actual_seed = random.randint(0, 1000000)
 
52
 
53
  generator = torch.Generator().manual_seed(actual_seed)
54
 
55
+ output = pipe(
56
  prompt=prompt,
57
  negative_prompt=negative_prompt,
58
  generator=generator