imagescientist commited on
Commit
7010b1d
·
1 Parent(s): d540dbc

remove old code

Browse files
Files changed (1) hide show
  1. app.py +30 -7
app.py CHANGED
@@ -1,10 +1,10 @@
1
- import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
8
 
9
  import fastbook
10
  from fastbook import *
@@ -13,8 +13,31 @@ import skimage
13
  from skimage import io as skio
14
  import numpy
15
  from PIL import Image, ImageEnhance
 
 
16
  def name_to_hrs (r): return float(round(float(os.path.basename(r)[0:-4].split("_")[1][1:])*(minutes/60)+5,2))
17
  def validation_split (r): return os.path.basename(r)[0:-4].split("_")[3] == "R0003" or os.path.basename(r)[0:-4].split("_")[3] == "R0006"
18
  def get_label_filename(name): return path/'labels'/f'{name.stem}_annotationLabels.tif'
19
- zebrafish_age_predictor = load_learner(path/'FishAge.pkl')
20
- zebrafish_classifier = load_learner(path/'FishSegmentation.pkl')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import gradio as gr
2
 
3
+ # def greet(name):
4
+ # return "Hello " + name + "!!"
5
 
6
+ # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
+ # iface.launch()
8
 
9
  import fastbook
10
  from fastbook import *
 
13
  from skimage import io as skio
14
  import numpy
15
  from PIL import Image, ImageEnhance
16
+ import torchvision.transforms as T
17
+
18
  def name_to_hrs (r): return float(round(float(os.path.basename(r)[0:-4].split("_")[1][1:])*(minutes/60)+5,2))
19
  def validation_split (r): return os.path.basename(r)[0:-4].split("_")[3] == "R0003" or os.path.basename(r)[0:-4].split("_")[3] == "R0006"
20
  def get_label_filename(name): return path/'labels'/f'{name.stem}_annotationLabels.tif'
21
+ zebrafish_age_predictor = load_learner('FishAge.pkl')
22
+ zebrafish_classifier = load_learner('FishSegmentation.pkl')
23
+ examples = ["5hr.tif", "12hr.tif", "24hr.tif"]
24
+ def process_zebrafish_image(img):
25
+
26
+ # out_pl.clear_output()
27
+ # enhancer = ImageEnhance.Brightness(img)
28
+ # factor = 10
29
+ # im_output = enhancer.enhance(factor)
30
+ # with out_pl: display(im_output.to_thumb(256,256))
31
+ age,tensor, tensor=zebrafish_age_predictor.predict(img)
32
+
33
+ pred,pred_idx,probs=zebrafish_classifier.predict(img)
34
+
35
+ # with out_pl_mask: pred.show(alpha=1, vmin=0, vmax=3, title='mask')
36
+ # lbl_pred.value = f'Predicted age: {age[0]};'
37
+ #return dict(zip(pred, map(float,age)))
38
+ return dict(zip(T.ToPILImage(pred), map(float,age)))
39
+
40
+ import gradio as gr
41
+
42
+ intf = gr.Interface(fn=process_zebrafish_image, inputs=gr.inputs.Image(shape=(512, 512)), outputs=[gr.outputs.Image(), gr.outputs.Label()]).launch(share=True)
43
+ intf.launch(inline=False)