Spaces:
Runtime error
Runtime error
Added Application file, requirements.txt and model
Browse files- app.py +22 -0
- requirements.txt +2 -0
- xres18.pkl +3 -0
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import skimage
|
4 |
+
import pathlib
|
5 |
+
|
6 |
+
plt = platform.system()
|
7 |
+
if plt == 'Linux' : pathlib.WindowsPath = pathlib.PosixPath
|
8 |
+
|
9 |
+
learn = load_learner('xres18.pkl')
|
10 |
+
|
11 |
+
labels = learn.dls.vocab
|
12 |
+
def predict(img):
|
13 |
+
img = PILImage.create(img)
|
14 |
+
pred,pred_idx,probs = learn.predict(img)
|
15 |
+
return {labels[i] : float(probs[i]) for i in range(len(labels))}
|
16 |
+
|
17 |
+
title = 'Cell Identifier'
|
18 |
+
description = 'A cell identifier detector trained on custom dataset with fastai. Created using Gradio and HuggingFace Spaces.'
|
19 |
+
examples = []
|
20 |
+
enable_queue = True
|
21 |
+
|
22 |
+
gr.Interface(fn=predict, input=gr.inputs.Image(shape=(512,512)), outputs=gr.outputs.Label(num_top_classes=3), title=title, description=description, examples=examples, enable_queue=enable_queue).launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|
xres18.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0ec3060d2e3a37f7f1ca417e7103c5d395da2578b46c5c2fa5c7f8f3575491bb
|
3 |
+
size 47134138
|