mouseland commited on
Commit
255910e
·
verified ·
1 Parent(s): 4be9a38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -13
app.py CHANGED
@@ -69,6 +69,7 @@ def plot_flows(y):
69
 
70
  def plot_outlines(img, masks):
71
  img = normalize99(img)
 
72
  outpix = []
73
  contours, hierarchy = cv2.findContours(masks.astype(np.int32), mode=cv2.RETR_FLOODFILL, method=cv2.CHAIN_APPROX_SIMPLE)
74
  for c in range(len(contours)):
@@ -118,8 +119,7 @@ def plot_overlay(img, masks):
118
  img_gray = img.astype(np.float32)
119
 
120
  img = normalize99(img_gray)
121
- img -= img.min()
122
- img /= img.max()
123
  HSV = np.zeros((img.shape[0], img.shape[1], 3), np.float32)
124
  HSV[:,:,2] = np.clip(img*1.5, 0, 1.0)
125
  for n in range(int(masks.max())):
@@ -224,8 +224,8 @@ def cellpose_segment(filepath, resize = 1000,max_iter = 250):
224
  fname_out = os.path.splitext(filepath[-1])[0]+"_outlines.png"
225
  outpix.save(fname_out) #"outlines.png")
226
 
227
- fname_flows = os.path.splitext(filepath[-1])[0]+"_flows.png"
228
- flows.save(fname_flows) #"outlines.png")
229
 
230
  if len(filepath)>1:
231
  b1 = gr.DownloadButton(visible=True, value = zip_path)
@@ -235,15 +235,6 @@ def cellpose_segment(filepath, resize = 1000,max_iter = 250):
235
 
236
  return outpix, flows, b1, b2
237
 
238
- # Gradio Interface
239
- #iface = gr.Interface(
240
- # fn=cellpose_segment,
241
- # inputs="image",
242
- # outputs=["image", "image", "image", "image"],
243
- # title="cellpose segmentation",
244
- # description="upload an image, then cellpose will segment it at a max size of 400x400 (for full functionality, 'pip install cellpose' locally)"
245
- #)
246
-
247
  def download_function():
248
  b1 = gr.DownloadButton("Download masks as TIFF", visible=False)
249
  b2 = gr.DownloadButton("Download outline image as PNG", visible=False)
 
69
 
70
  def plot_outlines(img, masks):
71
  img = normalize99(img)
72
+ img = np.clip(img, 0, 1)
73
  outpix = []
74
  contours, hierarchy = cv2.findContours(masks.astype(np.int32), mode=cv2.RETR_FLOODFILL, method=cv2.CHAIN_APPROX_SIMPLE)
75
  for c in range(len(contours)):
 
119
  img_gray = img.astype(np.float32)
120
 
121
  img = normalize99(img_gray)
122
+ #img = np.clip(img, 0, 1)
 
123
  HSV = np.zeros((img.shape[0], img.shape[1], 3), np.float32)
124
  HSV[:,:,2] = np.clip(img*1.5, 0, 1.0)
125
  for n in range(int(masks.max())):
 
224
  fname_out = os.path.splitext(filepath[-1])[0]+"_outlines.png"
225
  outpix.save(fname_out) #"outlines.png")
226
 
227
+ #fname_flows = os.path.splitext(filepath[-1])[0]+"_flows.png"
228
+ #flows.save(fname_flows) #"outlines.png")
229
 
230
  if len(filepath)>1:
231
  b1 = gr.DownloadButton(visible=True, value = zip_path)
 
235
 
236
  return outpix, flows, b1, b2
237
 
 
 
 
 
 
 
 
 
 
238
  def download_function():
239
  b1 = gr.DownloadButton("Download masks as TIFF", visible=False)
240
  b2 = gr.DownloadButton("Download outline image as PNG", visible=False)