Spaces:
Runtime error
Runtime error
Initial Commit
Browse files
app.py
CHANGED
|
@@ -26,7 +26,9 @@ def inference(image, input_label, model_choice):
|
|
| 26 |
sam.to(device=device)
|
| 27 |
predictor = SamPredictor(sam)
|
| 28 |
predictor.set_image(image)
|
| 29 |
-
|
|
|
|
|
|
|
| 30 |
input_label = np.array([1])
|
| 31 |
masks, scores, logits = predictor.predict(
|
| 32 |
point_coords=input_point,
|
|
@@ -36,9 +38,7 @@ def inference(image, input_label, model_choice):
|
|
| 36 |
mask = masks[0]
|
| 37 |
image2 = image.copy()
|
| 38 |
image2[mask, 0] = 255
|
| 39 |
-
image2[
|
| 40 |
-
int(input_label['label'].split(',')[1])-10:int(input_label['label'].split(',')[1])+10,
|
| 41 |
-
2] = 255
|
| 42 |
return image2
|
| 43 |
|
| 44 |
|
|
|
|
| 26 |
sam.to(device=device)
|
| 27 |
predictor = SamPredictor(sam)
|
| 28 |
predictor.set_image(image)
|
| 29 |
+
x = int(input_label['label'].split(',')[0])
|
| 30 |
+
y = int(input_label['label'].split(',')[1])
|
| 31 |
+
input_point = np.array([[x, y]])
|
| 32 |
input_label = np.array([1])
|
| 33 |
masks, scores, logits = predictor.predict(
|
| 34 |
point_coords=input_point,
|
|
|
|
| 38 |
mask = masks[0]
|
| 39 |
image2 = image.copy()
|
| 40 |
image2[mask, 0] = 255
|
| 41 |
+
image2[x-10:x+10, y-10:y+10, 2] = 255
|
|
|
|
|
|
|
| 42 |
return image2
|
| 43 |
|
| 44 |
|