Spaces:
Running on Zero
Running on Zero
Fix Space startup and inference robustness
#1
by merve HF Staff - opened
- __pycache__/app.cpython-312.pyc +0 -0
- app.py +5 -5
__pycache__/app.cpython-312.pyc
ADDED
|
Binary file (8.98 kB). View file
|
|
|
app.py
CHANGED
|
@@ -66,16 +66,16 @@ def sam_point_inference(image, x, y, *, slim=False):
|
|
| 66 |
|
| 67 |
def infer_point(img):
|
| 68 |
if img is None:
|
| 69 |
-
gr.Error("Please upload an image and select a point.")
|
| 70 |
if img["background"] is None:
|
| 71 |
-
gr.Error("Please upload an image and select a point.")
|
| 72 |
# background (original image) layers[0] ( point prompt) composite (total image)
|
| 73 |
image = img["background"].convert("RGB")
|
| 74 |
point_prompt = img["layers"][0]
|
| 75 |
total_image = img["composite"]
|
| 76 |
img_arr = np.array(point_prompt)
|
| 77 |
if not np.any(img_arr):
|
| 78 |
-
gr.Error("Please select a point on top of the image.")
|
| 79 |
else:
|
| 80 |
nonzero_indices = np.nonzero(img_arr)
|
| 81 |
img_arr = np.array(point_prompt)
|
|
@@ -90,10 +90,10 @@ def infer_box(prompts):
|
|
| 90 |
# background (original image) layers[0] ( point prompt) composite (total image)
|
| 91 |
image = prompts["image"]
|
| 92 |
if image is None:
|
| 93 |
-
gr.Error("Please upload an image and draw a box before submitting")
|
| 94 |
points = prompts["points"][0]
|
| 95 |
if points is None:
|
| 96 |
-
gr.Error("Please draw a box before submitting.")
|
| 97 |
print(points)
|
| 98 |
|
| 99 |
# x_min = points[0] x_max = points[3] y_min = points[1] y_max = points[4]
|
|
|
|
| 66 |
|
| 67 |
def infer_point(img):
|
| 68 |
if img is None:
|
| 69 |
+
raise gr.Error("Please upload an image and select a point.")
|
| 70 |
if img["background"] is None:
|
| 71 |
+
raise gr.Error("Please upload an image and select a point.")
|
| 72 |
# background (original image) layers[0] ( point prompt) composite (total image)
|
| 73 |
image = img["background"].convert("RGB")
|
| 74 |
point_prompt = img["layers"][0]
|
| 75 |
total_image = img["composite"]
|
| 76 |
img_arr = np.array(point_prompt)
|
| 77 |
if not np.any(img_arr):
|
| 78 |
+
raise gr.Error("Please select a point on top of the image.")
|
| 79 |
else:
|
| 80 |
nonzero_indices = np.nonzero(img_arr)
|
| 81 |
img_arr = np.array(point_prompt)
|
|
|
|
| 90 |
# background (original image) layers[0] ( point prompt) composite (total image)
|
| 91 |
image = prompts["image"]
|
| 92 |
if image is None:
|
| 93 |
+
raise gr.Error("Please upload an image and draw a box before submitting")
|
| 94 |
points = prompts["points"][0]
|
| 95 |
if points is None:
|
| 96 |
+
raise gr.Error("Please draw a box before submitting.")
|
| 97 |
print(points)
|
| 98 |
|
| 99 |
# x_min = points[0] x_max = points[3] y_min = points[1] y_max = points[4]
|