Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -20,11 +20,12 @@ model = UNet(
|
|
20 |
model.load_state_dict(torch.load("best_model.pth", map_location=torch.device('cpu')))
|
21 |
model.eval()
|
22 |
|
23 |
-
def greet(
|
24 |
|
25 |
|
26 |
# image = Image.open(image_path).convert("RGB")
|
27 |
-
image = np.array(image) / 255.0
|
|
|
28 |
image = image.astype(np.float32)
|
29 |
|
30 |
inference_transforms = A.Compose([
|
@@ -47,11 +48,29 @@ demo = gr.Interface(
|
|
47 |
fn=greet,
|
48 |
title="Histapathology segmentation",
|
49 |
inputs=[
|
50 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
],
|
52 |
outputs=[
|
53 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
54 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
)
|
56 |
|
57 |
demo.launch()
|
|
|
20 |
model.load_state_dict(torch.load("best_model.pth", map_location=torch.device('cpu')))
|
21 |
model.eval()
|
22 |
|
23 |
+
def greet(image):
|
24 |
|
25 |
|
26 |
# image = Image.open(image_path).convert("RGB")
|
27 |
+
# image = np.array(image) / 255.0
|
28 |
+
image = image /
|
29 |
image = image.astype(np.float32)
|
30 |
|
31 |
inference_transforms = A.Compose([
|
|
|
48 |
fn=greet,
|
49 |
title="Histapathology segmentation",
|
50 |
inputs=[
|
51 |
+
gr.Image(
|
52 |
+
label="Input image",
|
53 |
+
image_mode="RGB",
|
54 |
+
height=400,
|
55 |
+
type="numpy",
|
56 |
+
witdh=400,
|
57 |
+
)
|
58 |
],
|
59 |
outputs=[
|
60 |
+
gr.Image(
|
61 |
+
label="Model Prediction",
|
62 |
+
image_mode="RGB",
|
63 |
+
height=400,
|
64 |
+
witdh=400,
|
65 |
+
)
|
66 |
],
|
67 |
+
# examples=[
|
68 |
+
# os.path.join(os.path.dirname(__file__), "images/cheetah1.jpg"),
|
69 |
+
# os.path.join(os.path.dirname(__file__), "images/lion.jpg"),
|
70 |
+
# os.path.join(os.path.dirname(__file__), "images/logo.png"),
|
71 |
+
# os.path.join(os.path.dirname(__file__), "images/tower.jpg"),
|
72 |
+
# ],
|
73 |
+
|
74 |
)
|
75 |
|
76 |
demo.launch()
|