Spaces:
Runtime error
Runtime error
elapsed_time
Browse files
app.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
import modin.pandas as pd
|
3 |
import torch
|
|
|
|
|
4 |
import numpy as np
|
5 |
from PIL import Image
|
6 |
from diffusers import AutoPipelineForImage2Image
|
@@ -17,12 +19,16 @@ def resize(value,img):
|
|
17 |
return img
|
18 |
|
19 |
def infer(source_img, prompt, steps, seed, Strength):
|
|
|
20 |
generator = torch.Generator(device).manual_seed(seed)
|
21 |
if int(steps * Strength) < 1:
|
22 |
steps = math.ceil(1 / max(0.10, Strength))
|
23 |
source_image = resize(512, source_img)
|
24 |
source_image.save('source.png')
|
25 |
image = pipe(prompt, image=source_image, strength=Strength, guidance_scale=0.0, num_inference_steps=steps).images[0]
|
|
|
|
|
|
|
26 |
return image
|
27 |
|
28 |
gr.Interface(fn=infer, inputs=[
|
|
|
1 |
import gradio as gr
|
2 |
import modin.pandas as pd
|
3 |
import torch
|
4 |
+
import time
|
5 |
+
|
6 |
import numpy as np
|
7 |
from PIL import Image
|
8 |
from diffusers import AutoPipelineForImage2Image
|
|
|
19 |
return img
|
20 |
|
21 |
def infer(source_img, prompt, steps, seed, Strength):
|
22 |
+
start_time = time.time()
|
23 |
generator = torch.Generator(device).manual_seed(seed)
|
24 |
if int(steps * Strength) < 1:
|
25 |
steps = math.ceil(1 / max(0.10, Strength))
|
26 |
source_image = resize(512, source_img)
|
27 |
source_image.save('source.png')
|
28 |
image = pipe(prompt, image=source_image, strength=Strength, guidance_scale=0.0, num_inference_steps=steps).images[0]
|
29 |
+
end_time = time.time()
|
30 |
+
elapsed_time = end_time - start_time
|
31 |
+
print("生成时间",elapsed_time)
|
32 |
return image
|
33 |
|
34 |
gr.Interface(fn=infer, inputs=[
|