Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -6,44 +6,23 @@ import random
|
|
6 |
|
7 |
model_14b_id = "nvidia/Cosmos-Predict2-14B-Text2Image"
|
8 |
|
9 |
-
pipe_14b = Cosmos2TextToImagePipeline.from_pretrained(
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
pipe_14b.to("cuda")
|
14 |
-
|
15 |
-
scheduler = EDMEulerScheduler(
|
16 |
-
sigma_min=0.002,
|
17 |
-
sigma_max=80,
|
18 |
-
sigma_data=1.0,
|
19 |
-
sigma_schedule="karras",
|
20 |
-
num_train_timesteps=1000,
|
21 |
-
prediction_type="epsilon",
|
22 |
-
rho=7.0,
|
23 |
-
final_sigmas_type="sigma_min",
|
24 |
-
# use_flow_sigmas=True,
|
25 |
)
|
26 |
|
27 |
-
pipe_14b.
|
28 |
-
# pipe_2b.scheduler = scheduler
|
29 |
|
30 |
@spaces.GPU(duration=120)
|
31 |
-
def generate_image(
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
38 |
|
39 |
-
if model_choice == "14B":
|
40 |
-
pipe = pipe_14b
|
41 |
-
#pipe_2b.to("cpu")
|
42 |
-
|
43 |
-
#else:
|
44 |
-
# pipe = pipe_2b
|
45 |
-
# pipe_14b.to("cpu")
|
46 |
-
|
47 |
if randomize_seed:
|
48 |
actual_seed = random.randint(0, 1000000)
|
49 |
else:
|
@@ -51,7 +30,7 @@ def generate_image(prompt,
|
|
51 |
|
52 |
generator = torch.Generator().manual_seed(actual_seed)
|
53 |
|
54 |
-
output =
|
55 |
prompt=prompt,
|
56 |
negative_prompt=negative_prompt,
|
57 |
generator=generator
|
@@ -59,8 +38,6 @@ def generate_image(prompt,
|
|
59 |
|
60 |
return output, actual_seed
|
61 |
|
62 |
-
|
63 |
-
|
64 |
example_prompts = [
|
65 |
"A well-worn broom sweeps across a dusty wooden floor, its bristles gathering crumbs and flecks of debris in swift, rhythmic strokes. Dust motes dance in the sunbeams filtering through the window, glowing momentarily before settling. The quiet swish of straw brushing wood is interrupted only by the occasional creak of old floorboards. With each pass, the floor grows cleaner, restoring a sense of quiet order to the humble room.",
|
66 |
"A laundry machine whirs to life, tumbling colorful clothes behind the foggy glass door. Suds begin to form in a frothy dance, clinging to fabric as the drum spins. The gentle thud of shifting clothes creates a steady rhythm, like a heartbeat of the home. Outside the machine, a quiet calm fills the room, anticipation building for the softness and warmth of freshly laundered garments.",
|
|
|
6 |
|
7 |
model_14b_id = "nvidia/Cosmos-Predict2-14B-Text2Image"
|
8 |
|
9 |
+
pipe_14b = Cosmos2TextToImagePipeline.from_pretrained(
|
10 |
+
model_14b_id,
|
11 |
+
torch_dtype=torch.bfloat16
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
)
|
13 |
|
14 |
+
pipe_14b.to("cuda")
|
|
|
15 |
|
16 |
@spaces.GPU(duration=120)
|
17 |
+
def generate_image(
|
18 |
+
prompt,
|
19 |
+
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.",
|
20 |
+
seed=42,
|
21 |
+
randomize_seed=False,
|
22 |
+
model_choice="14B",
|
23 |
+
progress=gr.Progress(track_tqdm=True)
|
24 |
+
):
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
if randomize_seed:
|
27 |
actual_seed = random.randint(0, 1000000)
|
28 |
else:
|
|
|
30 |
|
31 |
generator = torch.Generator().manual_seed(actual_seed)
|
32 |
|
33 |
+
output = pipe_14b(
|
34 |
prompt=prompt,
|
35 |
negative_prompt=negative_prompt,
|
36 |
generator=generator
|
|
|
38 |
|
39 |
return output, actual_seed
|
40 |
|
|
|
|
|
41 |
example_prompts = [
|
42 |
"A well-worn broom sweeps across a dusty wooden floor, its bristles gathering crumbs and flecks of debris in swift, rhythmic strokes. Dust motes dance in the sunbeams filtering through the window, glowing momentarily before settling. The quiet swish of straw brushing wood is interrupted only by the occasional creak of old floorboards. With each pass, the floor grows cleaner, restoring a sense of quiet order to the humble room.",
|
43 |
"A laundry machine whirs to life, tumbling colorful clothes behind the foggy glass door. Suds begin to form in a frothy dance, clinging to fabric as the drum spins. The gentle thud of shifting clothes creates a steady rhythm, like a heartbeat of the home. Outside the machine, a quiet calm fills the room, anticipation building for the softness and warmth of freshly laundered garments.",
|