Saim8250 commited on
Commit
4eb1dad
·
verified ·
1 Parent(s): 49e38df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -19
app.py CHANGED
@@ -1,10 +1,7 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
- from PIL import Image
4
- import numpy as np
5
 
6
- # Use a pipeline as a high-level helper
7
- pipe = pipeline("mask-generation", model="lightmedsam")
8
 
9
  def predict(image_path):
10
  # Perform image segmentation
@@ -18,22 +15,11 @@ def predict(image_path):
18
 
19
  return segmented_image
20
 
21
- def colorize_mask(mask):
22
- # Assuming `mask` is a single-channel segmentation mask (grayscale)
23
- # You may need to adjust this function based on the specifics of your model's output
24
-
25
- # Convert single-channel mask to 3-channel (RGB) mask
26
- colored_mask = np.zeros((*mask.shape, 3), dtype=np.uint8)
27
- colored_mask[:, :, 0] = mask
28
- colored_mask[:, :, 1] = mask
29
- colored_mask[:, :, 2] = mask
30
-
31
- return colored_mask
32
-
33
  gr.Interface(
34
  predict,
35
- inputs=gr.Image(label="Upload medical image", type="filepath"),
36
- outputs=gr.Image(label="Segmented image"),
37
- title="Segmented medical image",
38
  allow_flagging="manual"
39
  ).launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
 
 
3
 
4
+ pipeline = pipeline(task="image-segmentation", model="Saim8250/litemedsam")
 
5
 
6
  def predict(image_path):
7
  # Perform image segmentation
 
15
 
16
  return segmented_image
17
 
18
+
 
 
 
 
 
 
 
 
 
 
 
19
  gr.Interface(
20
  predict,
21
+ inputs=gr.inputs.Image(label="Upload image", type="filepath"),
22
+ outputs=gr.outputs.Label(num_top_classes=2),
23
+ title="segmentation",
24
  allow_flagging="manual"
25
  ).launch()