Spaces:
Sleeping
Sleeping
Oliver Hamilton
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -2,10 +2,9 @@ import gradio as gr
|
|
2 |
import cv2
|
3 |
from geti_sdk.deployment import Deployment
|
4 |
from geti_sdk.utils import show_image_with_annotation_scene
|
5 |
-
import numpy as np
|
6 |
|
7 |
-
#
|
8 |
-
deployment = Deployment.from_folder("
|
9 |
deployment.load_inference_models(device="CPU")
|
10 |
|
11 |
def resize_image(image, target_dimension):
|
@@ -22,13 +21,13 @@ def infer(image):
|
|
22 |
return None, 'Error: No image provided'
|
23 |
|
24 |
image = resize_image(image, 1200)
|
25 |
-
|
26 |
-
prediction = deployment.infer(
|
27 |
output = show_image_with_annotation_scene(image, prediction, show_results=False)
|
28 |
output = cv2.cvtColor(output, cv2.COLOR_BGR2RGB)
|
29 |
return output, prediction.overview
|
30 |
|
31 |
-
|
32 |
fn=infer,
|
33 |
inputs="image",
|
34 |
outputs=["image", "text"],
|
@@ -37,4 +36,4 @@ interface = gr.Interface(
|
|
37 |
examples=[["eggsample1.jpg"], ["eggsample2.jpg"]]
|
38 |
)
|
39 |
|
40 |
-
|
|
|
2 |
import cv2
|
3 |
from geti_sdk.deployment import Deployment
|
4 |
from geti_sdk.utils import show_image_with_annotation_scene
|
|
|
5 |
|
6 |
+
#Load models
|
7 |
+
deployment = Deployment.from_folder("deployments")
|
8 |
deployment.load_inference_models(device="CPU")
|
9 |
|
10 |
def resize_image(image, target_dimension):
|
|
|
21 |
return None, 'Error: No image provided'
|
22 |
|
23 |
image = resize_image(image, 1200)
|
24 |
+
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
25 |
+
prediction = deployment.infer(image_rgb)
|
26 |
output = show_image_with_annotation_scene(image, prediction, show_results=False)
|
27 |
output = cv2.cvtColor(output, cv2.COLOR_BGR2RGB)
|
28 |
return output, prediction.overview
|
29 |
|
30 |
+
demo = gr.Interface(
|
31 |
fn=infer,
|
32 |
inputs="image",
|
33 |
outputs=["image", "text"],
|
|
|
36 |
examples=[["eggsample1.jpg"], ["eggsample2.jpg"]]
|
37 |
)
|
38 |
|
39 |
+
demo.launch()
|