multimodalart HF Staff commited on
Commit
5821869
·
verified ·
1 Parent(s): e781acc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -6
app.py CHANGED
@@ -1,23 +1,33 @@
1
- import os
2
- import subprocess
3
- os.chdir('diffusers_repo')
4
- subprocess.check_call(['pip', 'install', '.'])
5
  import gradio as gr
6
  import spaces
7
  import torch
8
- from diffusers import CosmosTextToImagePipeline
9
  import random
10
 
11
  model_14b_id = "diffusers-internal-dev/ct2i-14B"
12
  model_2b_id = "diffusers-internal-dev/ct2i-2B"
13
 
14
-
15
  pipe_14b = CosmosTextToImagePipeline.from_pretrained(model_14b_id, torch_dtype=torch.bfloat16)
16
  pipe_14b.to("cuda")
17
 
18
  pipe_2b = CosmosTextToImagePipeline.from_pretrained(model_2b_id, torch_dtype=torch.bfloat16)
19
  pipe_2b.to("cuda")
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  @spaces.GPU
22
  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)):
23
  # Select the appropriate pipeline based on model choice
 
 
 
 
 
1
  import gradio as gr
2
  import spaces
3
  import torch
4
+ from diffusers import CosmosTextToImagePipeline, EDMEulerScheduler
5
  import random
6
 
7
  model_14b_id = "diffusers-internal-dev/ct2i-14B"
8
  model_2b_id = "diffusers-internal-dev/ct2i-2B"
9
 
 
10
  pipe_14b = CosmosTextToImagePipeline.from_pretrained(model_14b_id, torch_dtype=torch.bfloat16)
11
  pipe_14b.to("cuda")
12
 
13
  pipe_2b = CosmosTextToImagePipeline.from_pretrained(model_2b_id, torch_dtype=torch.bfloat16)
14
  pipe_2b.to("cuda")
15
 
16
+ scheduler = EDMEulerScheduler(
17
+ sigma_min=0.002,
18
+ sigma_max=80,
19
+ sigma_data=1.0,
20
+ sigma_schedule="karras",
21
+ num_train_timesteps=1000,
22
+ prediction_type="epsilon",
23
+ rho=7.0,
24
+ final_sigmas_type="sigma_min",
25
+ use_flow_sigmas=True,
26
+ )
27
+
28
+ pipe_14b.scheduler = scheduler
29
+ 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