Spaces:
Sleeping
Sleeping
IZERE HIRWA Roger
commited on
Commit
·
7d4aa82
1
Parent(s):
8dfdfe9
vv
Browse files
app.py
CHANGED
@@ -42,16 +42,14 @@ def segment(image_pil: Image.Image, prompt: str):
|
|
42 |
# Convert PIL image to numpy array
|
43 |
image_np = np.array(image_pil)
|
44 |
|
45 |
-
# Ensure the model is explicitly set to CPU
|
46 |
-
grounder.to("cpu")
|
47 |
-
|
48 |
# Run GroundingDINO to get boxes for the prompt
|
49 |
boxes, _, _ = predict(
|
50 |
model=grounder,
|
51 |
-
image=image_np,
|
52 |
caption=prompt,
|
53 |
box_threshold=0.3,
|
54 |
-
text_threshold=0.25
|
|
|
55 |
)
|
56 |
if boxes.size == 0:
|
57 |
raise ValueError("No boxes found for prompt.")
|
@@ -97,3 +95,5 @@ if __name__ == "__main__":
|
|
97 |
parser.add_argument("--port", default=7860, type=int)
|
98 |
args = parser.parse_args()
|
99 |
app.run(host=args.host, port=args.port)
|
|
|
|
|
|
42 |
# Convert PIL image to numpy array
|
43 |
image_np = np.array(image_pil)
|
44 |
|
|
|
|
|
|
|
45 |
# Run GroundingDINO to get boxes for the prompt
|
46 |
boxes, _, _ = predict(
|
47 |
model=grounder,
|
48 |
+
image=torch.tensor(image_np).to(device), # Ensure image is on CPU
|
49 |
caption=prompt,
|
50 |
box_threshold=0.3,
|
51 |
+
text_threshold=0.25,
|
52 |
+
device="cpu" # Explicitly set device to CPU
|
53 |
)
|
54 |
if boxes.size == 0:
|
55 |
raise ValueError("No boxes found for prompt.")
|
|
|
95 |
parser.add_argument("--port", default=7860, type=int)
|
96 |
args = parser.parse_args()
|
97 |
app.run(host=args.host, port=args.port)
|
98 |
+
args = parser.parse_args()
|
99 |
+
app.run(host=args.host, port=args.port)
|