Trying fix variants
Browse files
app.py
CHANGED
@@ -43,32 +43,35 @@ def processar_profundidade(depth_arr: np.ndarray) -> Image.Image:
|
|
43 |
|
44 |
def processar_imagem(imagem: Image.Image):
|
45 |
# PrΓ©-processamento
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
outputs = depth_model(**inputs)
|
62 |
predicted_depth = outputs.predicted_depth
|
63 |
|
64 |
-
|
65 |
predicted_depth.unsqueeze(1),
|
66 |
-
size=
|
67 |
mode="bicubic",
|
68 |
align_corners=False
|
69 |
-
).squeeze()
|
70 |
|
71 |
-
|
|
|
|
|
|
|
|
|
72 |
|
73 |
|
74 |
# Interface Gradio
|
|
|
43 |
|
44 |
def processar_imagem(imagem: Image.Image):
|
45 |
# PrΓ©-processamento
|
46 |
+
print("Generating image with LoRA style...")
|
47 |
+
result = pipe(
|
48 |
+
prompt=full_prompt,
|
49 |
+
image=imagem,
|
50 |
+
num_inference_steps=15, # reduce if too slow
|
51 |
+
guidance_scale=7.5,
|
52 |
+
height=512, # reduce if you still get timeouts
|
53 |
+
width=512
|
54 |
+
)
|
55 |
+
image = result.images[0]
|
56 |
+
|
57 |
+
print("Running DPT Depth Estimation...")
|
58 |
+
inputs = feature_extractor(image, return_tensors="pt").to(device)
|
59 |
+
with torch.no_grad():
|
60 |
+
outputs = depth_model(**inputs)
|
|
|
61 |
predicted_depth = outputs.predicted_depth
|
62 |
|
63 |
+
prediction = torch.nn.functional.interpolate(
|
64 |
predicted_depth.unsqueeze(1),
|
65 |
+
size=image.size[::-1],
|
66 |
mode="bicubic",
|
67 |
align_corners=False
|
68 |
+
).squeeze()
|
69 |
|
70 |
+
depth_map_pil = processar_profundidade(prediction.cpu().numpy())
|
71 |
+
|
72 |
+
return image, depth_map_pil
|
73 |
+
|
74 |
+
# return resultado.images[0], processar_profundidade(depth_map)
|
75 |
|
76 |
|
77 |
# Interface Gradio
|