Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ import numpy as np
|
|
5 |
import spaces
|
6 |
import random
|
7 |
import string
|
8 |
-
from diffusers import
|
9 |
import torch
|
10 |
from pathos.multiprocessing import ProcessingPool as ProcessPoolExecutor
|
11 |
import requests
|
@@ -15,15 +15,15 @@ pool = ProcessPoolExecutor(64)
|
|
15 |
pool.__enter__()
|
16 |
|
17 |
#model_id = "runwayml/stable-diffusion-v1-5"
|
18 |
-
model_id = "stabilityai/stable-diffusion-3-medium"
|
19 |
|
20 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
21 |
if torch.cuda.is_available():
|
22 |
torch.cuda.max_memory_allocated(device=device)
|
23 |
-
pipe =
|
24 |
pipe = pipe.to(device)
|
25 |
else:
|
26 |
-
pipe =
|
27 |
pipe = pipe.to(device)
|
28 |
|
29 |
def translate(text,lang):
|
@@ -67,8 +67,8 @@ def infer(prompt):
|
|
67 |
height=4096,
|
68 |
width=4096,
|
69 |
negative_prompt="",
|
70 |
-
num_inference_steps=
|
71 |
-
guidance_scale=
|
72 |
).images[0].save(name)
|
73 |
return name
|
74 |
|
|
|
5 |
import spaces
|
6 |
import random
|
7 |
import string
|
8 |
+
from diffusers import StableDiffusion3Pipeline, SD3Transformer2DModel, FlowMatchEulerDiscreteScheduler
|
9 |
import torch
|
10 |
from pathos.multiprocessing import ProcessingPool as ProcessPoolExecutor
|
11 |
import requests
|
|
|
15 |
pool.__enter__()
|
16 |
|
17 |
#model_id = "runwayml/stable-diffusion-v1-5"
|
18 |
+
model_id = "stabilityai/stable-diffusion-3-medium-diffusers"
|
19 |
|
20 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
21 |
if torch.cuda.is_available():
|
22 |
torch.cuda.max_memory_allocated(device=device)
|
23 |
+
pipe = StableDiffusion3Pipeline.from_pretrained(model_id, torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
24 |
pipe = pipe.to(device)
|
25 |
else:
|
26 |
+
pipe = StableDiffusion3Pipeline.from_pretrained(model_id, use_safetensors=True)
|
27 |
pipe = pipe.to(device)
|
28 |
|
29 |
def translate(text,lang):
|
|
|
67 |
height=4096,
|
68 |
width=4096,
|
69 |
negative_prompt="",
|
70 |
+
num_inference_steps=100,
|
71 |
+
guidance_scale=10.0
|
72 |
).images[0].save(name)
|
73 |
return name
|
74 |
|