Gladiator commited on
Commit
308f32a
1 Parent(s): c384dba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -31
app.py CHANGED
@@ -1,37 +1,7 @@
1
- import os
2
- from PIL import Image
3
  import streamlit as st
4
- import ast
5
  import numpy as np
6
- import pandas as pd
7
  from cellpose import models, io, plot
8
- from pathlib import Path
9
-
10
-
11
- def rle_decode(mask_rle, shape=(520, 704)):
12
- """
13
- mask_rle: run-length as string formated (start length)
14
- shape: (height,width) of array to return
15
- Returns numpy array, 1 - mask, 0 - background
16
-
17
- """
18
- s = mask_rle.split()
19
- starts, lengths = [np.asarray(x, dtype=int) for x in (s[0:][::2], s[1:][::2])]
20
- starts -= 1
21
- ends = starts + lengths
22
- img = np.zeros(shape[0] * shape[1], dtype=np.uint8)
23
- for lo, hi in zip(starts, ends):
24
- img[lo:hi] = 1
25
- return img.reshape(shape)
26
-
27
-
28
- def rle_encode(img):
29
- pixels = img.flatten()
30
- pixels = np.concatenate([[0], pixels, [0]])
31
- runs = np.where(pixels[1:] != pixels[:-1])[0] + 1
32
- runs[1::2] -= runs[::2]
33
- return " ".join(str(x) for x in runs)
34
-
35
 
36
  def inference(image, model_path, **model_params):
37
  img = image
 
 
 
1
  import streamlit as st
 
2
  import numpy as np
3
+ from PIL import Image
4
  from cellpose import models, io, plot
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  def inference(image, model_path, **model_params):
7
  img = image