alibidaran commited on
Commit
96c54a2
1 Parent(s): 4b3cc5a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -10
app.py CHANGED
@@ -2,15 +2,12 @@ from openvino.runtime import Core
2
  import gradio as gr
3
  import numpy as np
4
  from PIL import Image
 
5
 
6
- def normalize(img):
7
- img=img.astype(np.float32)
8
- mean=(0.485, 0.456, 0.406)
9
- std=(0.229, 0.224, 0.225)
10
- img/=255.0
11
- img-=mean
12
- img/std
13
- return img
14
  def segment_image(filepath):
15
  image=cv2.imread(filepath)
16
  image=cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
@@ -26,8 +23,8 @@ def segment_image(filepath):
26
 
27
  demo=gr.Interface(fn=segment_image,inputs=gr.Image(type='filepath'),
28
  outputs=[gr.Image(type="pil"),gr.Image(type="pil")],
29
- examples=['R001_ch1_video_03_00-29-13-03.jpg',
30
- "R002_ch1_video_01_01-07-25-19.jpg,
31
  "R003_ch1_video_05_00-22-42-23.jpg",
32
  "R004_ch1_video_01_01-12-22-00.jpg",
33
  "R005_ch1_video_03_00-19-10-11.jpg",
 
2
  import gradio as gr
3
  import numpy as np
4
  from PIL import Image
5
+ from torchvision import models,transforms
6
 
7
+ tfms = transforms.Compose([
8
+ transforms.ToTensor(),
9
+ transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) # imagenet
10
+ ])
 
 
 
 
11
  def segment_image(filepath):
12
  image=cv2.imread(filepath)
13
  image=cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
 
23
 
24
  demo=gr.Interface(fn=segment_image,inputs=gr.Image(type='filepath'),
25
  outputs=[gr.Image(type="pil"),gr.Image(type="pil")],
26
+ examples=["R001_ch1_video_03_00-29-13-03.jpg",
27
+ "R002_ch1_video_01_01-07-25-19.jpg",
28
  "R003_ch1_video_05_00-22-42-23.jpg",
29
  "R004_ch1_video_01_01-12-22-00.jpg",
30
  "R005_ch1_video_03_00-19-10-11.jpg",