oliver9523 commited on
Commit
0d798b8
·
1 Parent(s): b7cb838

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -4
app.py CHANGED
@@ -1,7 +1,36 @@
1
  import gradio as gr
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  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
 
6
+ # Step 1: Load the deployment
7
+ deployment = Deployment.from_folder("deployment")
8
+ deployment.load_inference_models(device="CPU")
9
 
10
+ def resize_image(image, max_dimension):
11
+ height, width = image.shape[:2]
12
+ if max(height, width) <= max_dimension:
13
+ return image
14
+ if height > width:
15
+ new_height = max_dimension
16
+ new_width = int(width * (max_dimension / height))
17
+ else:
18
+ new_width = max_dimension
19
+ new_height = int(height * (max_dimension / width))
20
+ resized_image = cv2.resize(image, (new_width, new_height))
21
+ return resized_image
22
+
23
+ def infer(image=None):
24
+ if image is None:
25
+ return None
26
+ image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
27
+ prediction = deployment.infer(image)
28
+ output = show_image_with_annotation_scene(cv2.cvtColor(image, cv2.COLOR_BGR2RGB), prediction, show_results=False)
29
+ output = cv2.cvtColor(output, cv2.COLOR_BGR2RGB)
30
+ # output = cv2.resize(output, (224, 224))
31
+ return output
32
+
33
+ gr.Interface(fn=infer,
34
+ inputs='image',
35
+ outputs='image',
36
+ examples=["eggsample1.png", "eggsample2.png"]).launch()