Spaces:
Sleeping
Sleeping
Mehmet Batuhan Duman
commited on
Commit
·
ea1daab
1
Parent(s):
9f93ced
Changed scan func
Browse files
app.py
CHANGED
@@ -213,15 +213,19 @@ def scanmap(image_np, model, threshold=0.5):
|
|
213 |
|
214 |
# if probability is greater than threshold, draw a bounding box
|
215 |
if probabilities[0, 1].item() > threshold:
|
216 |
-
rect = patches.Rectangle((x, y), window_size[0], window_size[1], linewidth=1, edgecolor='r',
|
|
|
217 |
ax.add_patch(rect)
|
218 |
|
219 |
-
#
|
220 |
-
|
221 |
-
|
222 |
-
|
|
|
|
|
|
|
|
|
223 |
|
224 |
-
return Image.open(buf) # return PIL Image
|
225 |
|
226 |
def process_image(input_image):
|
227 |
image = Image.fromarray(input_image).convert("RGB")
|
@@ -244,6 +248,5 @@ outputs = [
|
|
244 |
]
|
245 |
|
246 |
iface = gr.Interface(fn=gradio_process_image, inputs=inputs, outputs=outputs)
|
247 |
-
iface.launch(
|
248 |
-
|
249 |
|
|
|
213 |
|
214 |
# if probability is greater than threshold, draw a bounding box
|
215 |
if probabilities[0, 1].item() > threshold:
|
216 |
+
rect = patches.Rectangle((x, y), window_size[0], window_size[1], linewidth=1, edgecolor='r',
|
217 |
+
facecolor='none')
|
218 |
ax.add_patch(rect)
|
219 |
|
220 |
+
# Convert matplotlib figure to PIL Image
|
221 |
+
fig.canvas.draw()
|
222 |
+
img_arr = np.array(fig.canvas.renderer.buffer_rgba())
|
223 |
+
plt.close(fig)
|
224 |
+
|
225 |
+
img = Image.fromarray(img_arr)
|
226 |
+
|
227 |
+
return img
|
228 |
|
|
|
229 |
|
230 |
def process_image(input_image):
|
231 |
image = Image.fromarray(input_image).convert("RGB")
|
|
|
248 |
]
|
249 |
|
250 |
iface = gr.Interface(fn=gradio_process_image, inputs=inputs, outputs=outputs)
|
251 |
+
iface.launch()
|
|
|
252 |
|