Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
# Assuming no shape needs to be specified directly in the constructor
|
| 4 |
image = gr.Image()
|
| 5 |
label = gr.Label()
|
|
|
|
| 1 |
+
# This Python 3 environment comes with many helpful analytics libraries installed
|
| 2 |
+
# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python
|
| 3 |
+
# For example, here's several helpful packages to load
|
| 4 |
+
|
| 5 |
+
import numpy as np # linear algebra
|
| 6 |
+
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
|
| 7 |
+
|
| 8 |
+
# Input data files are available in the read-only "../input/" directory
|
| 9 |
+
# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory
|
| 10 |
+
|
| 11 |
+
import os
|
| 12 |
+
for dirname, _, filenames in os.walk('/kaggle/input'):
|
| 13 |
+
for filename in filenames:
|
| 14 |
+
print(os.path.join(dirname, filename))
|
| 15 |
+
|
| 16 |
+
# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using "Save & Run All"
|
| 17 |
+
# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session
|
| 18 |
+
|
| 19 |
+
!pip install -Uqq fastai
|
| 20 |
+
!pip install gradio
|
| 21 |
+
|
| 22 |
+
import gradio as gr
|
| 23 |
+
|
| 24 |
import gradio as gr
|
| 25 |
|
| 26 |
+
from fastai.vision.all import*
|
| 27 |
+
|
| 28 |
+
def is_healthy(x): return x[0].isupper()
|
| 29 |
+
|
| 30 |
+
im = PILImage.create('/kaggle/input/healthy-cells/istockphoto-1376243518-612x612.jpg')
|
| 31 |
+
im.thumbnail((192,192))
|
| 32 |
+
im
|
| 33 |
+
|
| 34 |
+
learn = load_learner('/kaggle/input/011pdk/ML HT6 Model 011 perc.pkl')
|
| 35 |
+
|
| 36 |
+
learn.predict(im)
|
| 37 |
+
|
| 38 |
+
categories = ('Healthy Cell', 'Leukemia', 'Sickle Cell', 'Thalassemia')
|
| 39 |
+
def classify_image(img):
|
| 40 |
+
pred,idx,probs = learn.predict(img)
|
| 41 |
+
return dict(zip(categories, map(float,probs)))
|
| 42 |
+
|
| 43 |
+
classify_image(im)
|
| 44 |
+
|
| 45 |
+
import gradio as gr
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
|
| 49 |
# Assuming no shape needs to be specified directly in the constructor
|
| 50 |
image = gr.Image()
|
| 51 |
label = gr.Label()
|