ancebuc commited on
Commit
a34a00e
1 Parent(s): d3691a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py CHANGED
@@ -2,6 +2,33 @@ from huggingface_hub import from_pretrained_fastai
2
  import gradio as gr
3
  from fastai.vision.all import *
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  repo_id = "ancebuc/grapes-segmentation"
6
 
7
  learner = from_pretrained_fastai(repo_id)
 
2
  import gradio as gr
3
  from fastai.vision.all import *
4
 
5
+ class TargetMaskConvertTransform(ItemTransform):
6
+ def __init__(self):
7
+ pass
8
+ def encodes(self, x):
9
+ img,mask = x
10
+
11
+ #Convert to array
12
+ mask = np.array(mask)
13
+
14
+ # Uvas
15
+ mask[mask==255]=1
16
+
17
+ # Hojas
18
+ mask[mask==150]=2
19
+
20
+ # Poste
21
+ mask[mask==76]=3
22
+ mask[mask==74]=3
23
+
24
+ # Madera
25
+ mask[mask==29]=4
26
+ mask[mask==25]=4
27
+
28
+ # Back to PILMask
29
+ mask = PILMask.create(mask)
30
+ return img, mask
31
+
32
  repo_id = "ancebuc/grapes-segmentation"
33
 
34
  learner = from_pretrained_fastai(repo_id)