Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -59,12 +59,12 @@ class calculateDuration:
|
|
59 |
@spaces.GPU(duration=120)
|
60 |
@torch.inference_mode()
|
61 |
def generate_image(prompt, steps, seed, cfg_scale, width, height, progress):
|
62 |
-
|
63 |
-
with calculateDuration("Generating image"):
|
64 |
-
# Generate image
|
65 |
pipe.to(device)
|
66 |
generator = torch.Generator(device=device).manual_seed(seed)
|
67 |
-
|
|
|
|
|
68 |
generated_image = pipe(
|
69 |
prompt=prompt,
|
70 |
num_inference_steps=steps,
|
@@ -74,7 +74,7 @@ def generate_image(prompt, steps, seed, cfg_scale, width, height, progress):
|
|
74 |
generator=generator,
|
75 |
).images[0]
|
76 |
|
77 |
-
progress(99, "Generate success!")
|
78 |
return generated_image
|
79 |
|
80 |
|
@@ -135,9 +135,11 @@ def run_lora(prompt, lora_strings_json, cfg_scale, steps, randomize_seed, seed,
|
|
135 |
# Generate image
|
136 |
error_message = ""
|
137 |
try:
|
|
|
138 |
final_image = generate_image(prompt, steps, seed, cfg_scale, width, height, progress)
|
139 |
except Exception as e:
|
140 |
error_message = str(e)
|
|
|
141 |
final_image = None
|
142 |
|
143 |
if final_image:
|
|
|
59 |
@spaces.GPU(duration=120)
|
60 |
@torch.inference_mode()
|
61 |
def generate_image(prompt, steps, seed, cfg_scale, width, height, progress):
|
62 |
+
with calculateDuration(f"Make a new generator:${seed}"):
|
|
|
|
|
63 |
pipe.to(device)
|
64 |
generator = torch.Generator(device=device).manual_seed(seed)
|
65 |
+
|
66 |
+
with calculateDuration("Generating image"):
|
67 |
+
# Generate image
|
68 |
generated_image = pipe(
|
69 |
prompt=prompt,
|
70 |
num_inference_steps=steps,
|
|
|
74 |
generator=generator,
|
75 |
).images[0]
|
76 |
|
77 |
+
progress(99, "Generate image success!")
|
78 |
return generated_image
|
79 |
|
80 |
|
|
|
135 |
# Generate image
|
136 |
error_message = ""
|
137 |
try:
|
138 |
+
print("Start applying for zeroGPU resources")
|
139 |
final_image = generate_image(prompt, steps, seed, cfg_scale, width, height, progress)
|
140 |
except Exception as e:
|
141 |
error_message = str(e)
|
142 |
+
print("Run error", e)
|
143 |
final_image = None
|
144 |
|
145 |
if final_image:
|