Spaces:
Sleeping
Sleeping
Himanshu-AT
commited on
Commit
·
0ef453d
1
Parent(s):
3970027
update approach + add logs
Browse files
app.py
CHANGED
@@ -79,19 +79,30 @@ def calculate_optimal_dimensions(image: Image.Image):
|
|
79 |
@spaces.GPU(durations=300)
|
80 |
def infer(edit_images, prompt, lora_model, strength, seed=42, randomize_seed=False, guidance_scale=3.5, num_inference_steps=28, progress=gr.Progress(track_tqdm=True)):
|
81 |
# pipe.enable_xformers_memory_efficient_attention()
|
|
|
82 |
|
83 |
if lora_model != "None":
|
84 |
pipe.load_lora_weights(lora_models[lora_model])
|
85 |
pipe.enable_lora()
|
86 |
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
width, height = calculate_optimal_dimensions(image)
|
89 |
-
mask = edit_images["layers"][0]
|
90 |
if randomize_seed:
|
91 |
seed = random.randint(0, MAX_SEED)
|
92 |
|
93 |
# controlImage = processor(image)
|
94 |
-
|
95 |
image = pipe(
|
96 |
# mask_image_latent=vae.encode(controlImage),
|
97 |
prompt=prompt,
|
|
|
79 |
@spaces.GPU(durations=300)
|
80 |
def infer(edit_images, prompt, lora_model, strength, seed=42, randomize_seed=False, guidance_scale=3.5, num_inference_steps=28, progress=gr.Progress(track_tqdm=True)):
|
81 |
# pipe.enable_xformers_memory_efficient_attention()
|
82 |
+
gr.Info("Infering")
|
83 |
|
84 |
if lora_model != "None":
|
85 |
pipe.load_lora_weights(lora_models[lora_model])
|
86 |
pipe.enable_lora()
|
87 |
|
88 |
+
image_path = edit_images["background"]
|
89 |
+
mask_path = edit_images["layers"][0]
|
90 |
+
|
91 |
+
gr.info("starting checks")
|
92 |
+
|
93 |
+
image: Image.Image = Image.open(image_path)
|
94 |
+
mask: Image.Image = Image.open(mask_path)
|
95 |
+
|
96 |
+
if not image:
|
97 |
+
gr.Info("Please upload an image.")
|
98 |
+
return None, None
|
99 |
+
|
100 |
width, height = calculate_optimal_dimensions(image)
|
|
|
101 |
if randomize_seed:
|
102 |
seed = random.randint(0, MAX_SEED)
|
103 |
|
104 |
# controlImage = processor(image)
|
105 |
+
gr.info("generating image")
|
106 |
image = pipe(
|
107 |
# mask_image_latent=vae.encode(controlImage),
|
108 |
prompt=prompt,
|