ds1david commited on
Commit
8ddec5a
Β·
1 Parent(s): 75ebedf

Trying fix variants

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -28,9 +28,17 @@ depth_model = DPTForDepthEstimation.from_pretrained("Intel/dpt-large").to(device
28
 
29
 
30
  def processar_profundidade(depth_arr: np.ndarray) -> Image.Image:
31
- depth_normalized = (depth_arr - depth_arr.min()) / (depth_arr.max() - depth_arr.min() + 1e-8)
32
- depth_img = Image.fromarray((depth_normalized * 255).astype(np.uint8))
33
- return ImageOps.autocontrast(depth_img)
 
 
 
 
 
 
 
 
34
 
35
 
36
  def processar_imagem(imagem: Image.Image):
 
28
 
29
 
30
  def processar_profundidade(depth_arr: np.ndarray) -> Image.Image:
31
+ d_min, d_max = depth_arr.min(), depth_arr.max()
32
+ depth_stretched = (depth_arr - d_min) / (d_max - d_min + 1e-8)
33
+ depth_stretched = (depth_stretched * 255).astype(np.uint8)
34
+
35
+ depth_pil = Image.fromarray(depth_stretched)
36
+ depth_pil = ImageOps.autocontrast(depth_pil)
37
+
38
+ enhancer = ImageEnhance.Sharpness(depth_pil)
39
+ depth_pil = enhancer.enhance(2.0)
40
+
41
+ return depth_pil
42
 
43
 
44
  def processar_imagem(imagem: Image.Image):