Oliver Hamilton commited on
Commit
ec3cee2
·
verified ·
1 Parent(s): eeb1b28

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
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
- # Step 1: Load the deployment
8
- deployment = Deployment.from_folder("deployment2")
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
- image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
26
- prediction = deployment.infer(image)
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
- interface = gr.Interface(
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
- interface.launch(share=True)
 
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()