Spaces:
Sleeping
Sleeping
Commit
·
9d83fe7
1
Parent(s):
959cf76
Update model.py
Browse files
model.py
CHANGED
@@ -76,23 +76,25 @@ class Model(LabelStudioMLBase):
|
|
76 |
x, y, x2, y2 = tuple(box)
|
77 |
|
78 |
if self.id2label[label.item()] == 'Propuesta':
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
96 |
|
97 |
result_list.append({
|
98 |
'id': label_id,
|
|
|
76 |
x, y, x2, y2 = tuple(box)
|
77 |
|
78 |
if self.id2label[label.item()] == 'Propuesta':
|
79 |
+
with torch.no_grad():
|
80 |
+
pred_label_id = str(uuid4())
|
81 |
+
image = image.crop((x.item(), y.item(), x2.item(), y2.item()))
|
82 |
+
inputs = self.seg_image_processor(images=image, return_tensors="pt")
|
83 |
+
logits = self.seg_model(**inputs).logits
|
84 |
+
logits = torch.exp(logits)
|
85 |
+
print(logits)
|
86 |
+
preds = logits > 0.5
|
87 |
+
preds = [self.seg_id2label[i] for i, pred in enumerate(preds)]
|
88 |
+
preds = ["No Reportado"] if "No Reportado" in preds else preds
|
89 |
+
result_list.append({
|
90 |
+
"value": {
|
91 |
+
"choices": preds
|
92 |
+
},
|
93 |
+
"id": pred_label_id,
|
94 |
+
"from_name": "propuesta",
|
95 |
+
"to_name": "image",
|
96 |
+
"type": "choices"
|
97 |
+
})
|
98 |
|
99 |
result_list.append({
|
100 |
'id': label_id,
|