Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -263,16 +263,23 @@ def predict(image):
|
|
263 |
if len(input_shape) == 4 and input_shape[0] == 1:
|
264 |
image = np.expand_dims(image, axis=0)
|
265 |
image = image.astype(np.float32)
|
|
|
|
|
266 |
|
267 |
# Make prediction
|
268 |
output = model.run(None, {input_name: image})
|
|
|
|
|
269 |
|
270 |
-
print("type output:", type(output))
|
271 |
-
print(output)
|
272 |
|
273 |
# Postprocess output image
|
274 |
|
275 |
annotated_img = output[0]
|
|
|
|
|
|
|
276 |
# annotated_img = (output[0] / 255.0 - mean)/std
|
277 |
# annotated_img = classes[output[0][0].argmax(0)]
|
278 |
print("Annotated image type:", type(annotated_img))
|
@@ -301,8 +308,8 @@ def predict(image):
|
|
301 |
demo = gr.Interface(
|
302 |
fn=predict,
|
303 |
inputs=gr.Image(sources=["webcam"], type="numpy"), # Accepts image input
|
304 |
-
|
305 |
-
outputs=gr.Image(type="numpy"), # Accepts image input
|
306 |
)
|
307 |
|
308 |
if __name__ == "__main__":
|
|
|
263 |
if len(input_shape) == 4 and input_shape[0] == 1:
|
264 |
image = np.expand_dims(image, axis=0)
|
265 |
image = image.astype(np.float32)
|
266 |
+
|
267 |
+
print("Input image shape:", image.shape)
|
268 |
|
269 |
# Make prediction
|
270 |
output = model.run(None, {input_name: image})
|
271 |
+
|
272 |
+
print("Output shape:", output.shape)
|
273 |
|
274 |
+
# print("type output:", type(output))
|
275 |
+
# print(output)
|
276 |
|
277 |
# Postprocess output image
|
278 |
|
279 |
annotated_img = output[0]
|
280 |
+
|
281 |
+
print("Output[0] image shape:", annotated_img.shape)
|
282 |
+
|
283 |
# annotated_img = (output[0] / 255.0 - mean)/std
|
284 |
# annotated_img = classes[output[0][0].argmax(0)]
|
285 |
print("Annotated image type:", type(annotated_img))
|
|
|
308 |
demo = gr.Interface(
|
309 |
fn=predict,
|
310 |
inputs=gr.Image(sources=["webcam"], type="numpy"), # Accepts image input
|
311 |
+
outputs="image" # Customize based on your output format
|
312 |
+
# outputs=gr.Image(type="numpy"), # Accepts image input
|
313 |
)
|
314 |
|
315 |
if __name__ == "__main__":
|