Spaces:
Running
on
Zero
Running
on
Zero
bugfix
Browse files
app.py
CHANGED
@@ -42,15 +42,21 @@ class calculateDuration:
|
|
42 |
|
43 |
def __enter__(self):
|
44 |
self.start_time = time.time()
|
|
|
|
|
45 |
return self
|
46 |
|
47 |
def __exit__(self, exc_type, exc_value, traceback):
|
48 |
self.end_time = time.time()
|
49 |
self.elapsed_time = self.end_time - self.start_time
|
|
|
|
|
50 |
if self.activity_name:
|
51 |
print(f"Elapsed time for {self.activity_name}: {self.elapsed_time:.6f} seconds")
|
52 |
else:
|
53 |
print(f"Elapsed time: {self.elapsed_time:.6f} seconds")
|
|
|
|
|
54 |
|
55 |
# ηζεΎεηε½ζ°
|
56 |
@spaces.GPU
|
@@ -60,6 +66,7 @@ def generate_image(prompt, steps, seed, cfg_scale, width, height, progress):
|
|
60 |
generator = torch.Generator(device=device).manual_seed(seed)
|
61 |
with calculateDuration("Generating image"):
|
62 |
# Generate image
|
|
|
63 |
generated_image = pipe(
|
64 |
prompt=prompt,
|
65 |
num_inference_steps=steps,
|
@@ -95,7 +102,7 @@ def upload_image_to_r2(image, account_id, access_key, secret_key, bucket_name):
|
|
95 |
|
96 |
return image_file
|
97 |
|
98 |
-
def run_lora(prompt, lora_strings_json, cfg_scale, steps, randomize_seed, seed, width, height,
|
99 |
|
100 |
# Load LoRA weights
|
101 |
if lora_strings_json:
|
@@ -164,14 +171,13 @@ with gr.Blocks(css=css) as demo:
|
|
164 |
with gr.Row():
|
165 |
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0, randomize=True)
|
166 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
167 |
-
lora_scale = gr.Slider(label="LoRA Scale", minimum=0, maximum=1, step=0.01, value=0.5)
|
168 |
|
169 |
with gr.Row():
|
170 |
-
width = gr.Slider(label="Width", minimum=256, maximum=1536, step=64, value=
|
171 |
-
height = gr.Slider(label="Height", minimum=256, maximum=1536, step=64, value=
|
172 |
|
173 |
with gr.Row():
|
174 |
-
cfg_scale = gr.Slider(label="CFG Scale", minimum=1, maximum=20, step=0.5, value=
|
175 |
steps = gr.Slider(label="Steps", minimum=1, maximum=50, step=1, value=28)
|
176 |
|
177 |
upload_to_r2 = gr.Checkbox(label="Upload to R2", value=False)
|
@@ -195,7 +201,6 @@ with gr.Blocks(css=css) as demo:
|
|
195 |
seed,
|
196 |
width,
|
197 |
height,
|
198 |
-
lora_scale,
|
199 |
upload_to_r2,
|
200 |
account_id,
|
201 |
access_key,
|
|
|
42 |
|
43 |
def __enter__(self):
|
44 |
self.start_time = time.time()
|
45 |
+
self.start_time_formatted = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(self.start_time))
|
46 |
+
print(f"Activity: {self.activity_name}, Start time: {self.start_time_formatted}")
|
47 |
return self
|
48 |
|
49 |
def __exit__(self, exc_type, exc_value, traceback):
|
50 |
self.end_time = time.time()
|
51 |
self.elapsed_time = self.end_time - self.start_time
|
52 |
+
self.end_time_formatted = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(self.end_time))
|
53 |
+
|
54 |
if self.activity_name:
|
55 |
print(f"Elapsed time for {self.activity_name}: {self.elapsed_time:.6f} seconds")
|
56 |
else:
|
57 |
print(f"Elapsed time: {self.elapsed_time:.6f} seconds")
|
58 |
+
|
59 |
+
print(f"Activity: {self.activity_name}, End time: {self.start_time_formatted}")
|
60 |
|
61 |
# ηζεΎεηε½ζ°
|
62 |
@spaces.GPU
|
|
|
66 |
generator = torch.Generator(device=device).manual_seed(seed)
|
67 |
with calculateDuration("Generating image"):
|
68 |
# Generate image
|
69 |
+
print(prompt, steps, seed, cfg_scale, width, height)
|
70 |
generated_image = pipe(
|
71 |
prompt=prompt,
|
72 |
num_inference_steps=steps,
|
|
|
102 |
|
103 |
return image_file
|
104 |
|
105 |
+
def run_lora(prompt, lora_strings_json, cfg_scale, steps, randomize_seed, seed, width, height, upload_to_r2, account_id, access_key, secret_key, bucket, progress=gr.Progress(track_tqdm=True)):
|
106 |
|
107 |
# Load LoRA weights
|
108 |
if lora_strings_json:
|
|
|
171 |
with gr.Row():
|
172 |
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0, randomize=True)
|
173 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
|
|
174 |
|
175 |
with gr.Row():
|
176 |
+
width = gr.Slider(label="Width", minimum=256, maximum=1536, step=64, value=1024)
|
177 |
+
height = gr.Slider(label="Height", minimum=256, maximum=1536, step=64, value=1024)
|
178 |
|
179 |
with gr.Row():
|
180 |
+
cfg_scale = gr.Slider(label="CFG Scale", minimum=1, maximum=20, step=0.5, value=3.5)
|
181 |
steps = gr.Slider(label="Steps", minimum=1, maximum=50, step=1, value=28)
|
182 |
|
183 |
upload_to_r2 = gr.Checkbox(label="Upload to R2", value=False)
|
|
|
201 |
seed,
|
202 |
width,
|
203 |
height,
|
|
|
204 |
upload_to_r2,
|
205 |
account_id,
|
206 |
access_key,
|