multimodalart HF Staff commited on
Commit
e57b5c6
·
verified ·
1 Parent(s): ec066d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -6
app.py CHANGED
@@ -7,11 +7,19 @@ import random
7
  model_14b_id = "diffusers-internal-dev/ct2i-14B"
8
  model_2b_id = "diffusers-internal-dev/ct2i-2B"
9
 
10
- pipe_14b = Cosmos2TextToImagePipeline.from_pretrained(model_14b_id, torch_dtype=torch.bfloat16)
11
- pipe_14b.to("cuda")
 
 
12
 
13
- pipe_2b = Cosmos2TextToImagePipeline.from_pretrained(model_2b_id, text_encoder=pipe_14b.text_encoder, safety_checker=pipe_14b.safety_checker, vae=pipe_14b.vae, tokenizer=pipe_14b.tokenizer, torch_dtype=torch.bfloat16)
14
- pipe_2b.to("cuda")
 
 
 
 
 
 
15
 
16
  scheduler = EDMEulerScheduler(
17
  sigma_min=0.002,
@@ -30,11 +38,13 @@ pipe_2b.scheduler = scheduler
30
 
31
  @spaces.GPU
32
  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)):
33
- # Select the appropriate pipeline based on model choice
34
  if model_choice == "14B":
35
  pipe = pipe_14b
36
- else: # "2B Model"
 
37
  pipe = pipe_2b
 
38
 
39
  if randomize_seed:
40
  actual_seed = random.randint(0, 1000000)
 
7
  model_14b_id = "diffusers-internal-dev/ct2i-14B"
8
  model_2b_id = "diffusers-internal-dev/ct2i-2B"
9
 
10
+ pipe_14b = Cosmos2TextToImagePipeline.from_pretrained(model_14b_id,
11
+ revision="refs/pr/1",
12
+ torch_dtype=torch.bfloat16
13
+ )
14
 
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,
 
38
 
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
+ pipe.to("cuda")
45
+ else:
46
  pipe = pipe_2b
47
+ pipe.to("cuda")
48
 
49
  if randomize_seed:
50
  actual_seed = random.randint(0, 1000000)