Spaces:
Runtime error
Runtime error
app.py
CHANGED
@@ -6,7 +6,7 @@ from PIL import Image
|
|
6 |
from diffusers import LCMScheduler, AutoPipelineForImage2Image
|
7 |
from diffusers.utils import load_image
|
8 |
import math
|
9 |
-
|
10 |
model_id = "segmind/Segmind-Vega"
|
11 |
adapter_id = "segmind/Segmind-VegaRT"
|
12 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
@@ -23,12 +23,16 @@ def resize(value,img):
|
|
23 |
return img
|
24 |
|
25 |
def infer(source_img, prompt, steps, seed, Strength):
|
|
|
26 |
generator = torch.Generator(device).manual_seed(seed)
|
27 |
if int(steps * Strength) < 1:
|
28 |
steps = math.ceil(1 / max(0.10, Strength))
|
29 |
source_image = resize(512, source_img)
|
30 |
source_image.save('source.png')
|
31 |
image = pipe(prompt, image=source_image, strength=Strength, guidance_scale=0.0, num_inference_steps=steps).images[0]
|
|
|
|
|
|
|
32 |
return image
|
33 |
|
34 |
gr.Interface(fn=infer, inputs=[
|
|
|
6 |
from diffusers import LCMScheduler, AutoPipelineForImage2Image
|
7 |
from diffusers.utils import load_image
|
8 |
import math
|
9 |
+
import time
|
10 |
model_id = "segmind/Segmind-Vega"
|
11 |
adapter_id = "segmind/Segmind-VegaRT"
|
12 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
23 |
return img
|
24 |
|
25 |
def infer(source_img, prompt, steps, seed, Strength):
|
26 |
+
start = time.time()
|
27 |
generator = torch.Generator(device).manual_seed(seed)
|
28 |
if int(steps * Strength) < 1:
|
29 |
steps = math.ceil(1 / max(0.10, Strength))
|
30 |
source_image = resize(512, source_img)
|
31 |
source_image.save('source.png')
|
32 |
image = pipe(prompt, image=source_image, strength=Strength, guidance_scale=0.0, num_inference_steps=steps).images[0]
|
33 |
+
end = time.time()
|
34 |
+
print("步数",steps)
|
35 |
+
print("时间",end-start)
|
36 |
return image
|
37 |
|
38 |
gr.Interface(fn=infer, inputs=[
|