PablitoGil14 commited on
Commit
87fccf6
·
verified ·
1 Parent(s): bdfb04d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py CHANGED
@@ -8,6 +8,29 @@ import torch
8
 
9
  # Cargar modelo desde Hugging Face Hub
10
  model_path = hf_hub_download(repo_id="PablitoGil14/AP-Practica3", filename="model.pkl")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  learn = load_learner(model_path)
12
 
13
  def segmentar(img: Image.Image):
 
8
 
9
  # Cargar modelo desde Hugging Face Hub
10
  model_path = hf_hub_download(repo_id="PablitoGil14/AP-Practica3", filename="model.pkl")
11
+
12
+ class TargetMaskConvertTransform(ItemTransform):
13
+ def __init__(self):
14
+ pass
15
+ def encodes(self, x):
16
+ img,mask = x
17
+
18
+ #Convert to array
19
+ mask = np.array(mask)
20
+
21
+ mask[(mask!=255) & (mask!=150) & (mask!=76) & (mask!=74) & (mask!=29) & (mask!=25)]=0
22
+ mask[mask==255]=1
23
+ mask[mask==150]=2
24
+ mask[mask==76]=4
25
+ mask[mask==74]=4
26
+ mask[mask==29]=3
27
+ mask[mask==25]=3
28
+
29
+ # Back to PILMask
30
+ mask = PILMask.create(mask)
31
+ return img, mask
32
+
33
+
34
  learn = load_learner(model_path)
35
 
36
  def segmentar(img: Image.Image):