Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -79,11 +79,12 @@ from fastsam import FastSAM, FastSAMPrompt
|
|
| 79 |
|
| 80 |
model = FastSAM('./FastSAM.pt')
|
| 81 |
DEVICE = 'cpu'
|
| 82 |
-
IMAGE_PATH = 'sam.jpg'
|
| 83 |
def segment_solar_panel(img):
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
|
|
|
|
|
|
| 87 |
|
| 88 |
# everything prompt
|
| 89 |
ann = prompt_process.everything_prompt()
|
|
@@ -99,8 +100,8 @@ def segment_solar_panel(img):
|
|
| 99 |
# point_label default [0] [1,0] 0:background, 1:foreground
|
| 100 |
ann = prompt_process.point_prompt(points=[[620, 360]], pointlabel=[1])
|
| 101 |
|
| 102 |
-
prompt_process.plot(annotations=ann,output_path='./
|
| 103 |
-
return Image.Open('./
|
| 104 |
|
| 105 |
|
| 106 |
import gradio as gr
|
|
|
|
| 79 |
|
| 80 |
model = FastSAM('./FastSAM.pt')
|
| 81 |
DEVICE = 'cpu'
|
|
|
|
| 82 |
def segment_solar_panel(img):
|
| 83 |
+
# os.system('python Inference.py --model_path FastSAM.pt --img_path bus.jpg --text_prompt "solar panel grids"')
|
| 84 |
+
img = img.convert("RGB")
|
| 85 |
+
|
| 86 |
+
everything_results = model(img, device=DEVICE, retina_masks=True, imgsz=1024, conf=0.4, iou=0.9,)
|
| 87 |
+
prompt_process = FastSAMPrompt(img, everything_results, device=DEVICE)
|
| 88 |
|
| 89 |
# everything prompt
|
| 90 |
ann = prompt_process.everything_prompt()
|
|
|
|
| 100 |
# point_label default [0] [1,0] 0:background, 1:foreground
|
| 101 |
ann = prompt_process.point_prompt(points=[[620, 360]], pointlabel=[1])
|
| 102 |
|
| 103 |
+
prompt_process.plot(annotations=ann,output_path='./bus.jpg',)
|
| 104 |
+
return Image.Open('./bus.jpg')
|
| 105 |
|
| 106 |
|
| 107 |
import gradio as gr
|