Spaces:
Sleeping
Sleeping
update_pipiline
Browse files
app.py
CHANGED
@@ -1,23 +1,22 @@
|
|
1 |
# -*- coding: utf-8 -*-
|
2 |
-
"""gradioApp.ipynb
|
3 |
|
4 |
-
Automatically generated by Colaboratory.
|
5 |
-
|
6 |
-
Original file is located at
|
7 |
-
https://colab.research.google.com/drive/19rOnZUE7tNaMyAjlhnO4vLKb8mojrf2V
|
8 |
-
"""
|
9 |
-
|
10 |
-
# Commented out IPython magic to ensure Python compatibility.
|
11 |
# %%capture
|
12 |
# #Use capture to not show the output of installing the libraries!
|
13 |
# !pip install gradio
|
14 |
|
|
|
15 |
import gradio as gr
|
16 |
import numpy as np
|
17 |
import tensorflow as tf
|
|
|
18 |
|
19 |
-
model
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
def classify_image(inp):
|
23 |
inp = inp.reshape((-1, 224, 224, 3))
|
@@ -26,9 +25,11 @@ def classify_image(inp):
|
|
26 |
confidences = {labels[i]: float(prediction[0][i]) for i in range(2)}
|
27 |
return confidences
|
28 |
|
|
|
29 |
gr.Interface(fn=classify_image,
|
30 |
inputs=gr.Image(shape=(224, 224)),
|
31 |
outputs=gr.Label(num_top_classes = 2),
|
32 |
title="Demo",
|
33 |
-
description="Here's a sample image classification. Enjoy!",
|
|
|
34 |
).launch(share = True)
|
|
|
1 |
# -*- coding: utf-8 -*-
|
|
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
# %%capture
|
4 |
# #Use capture to not show the output of installing the libraries!
|
5 |
# !pip install gradio
|
6 |
|
7 |
+
|
8 |
import gradio as gr
|
9 |
import numpy as np
|
10 |
import tensorflow as tf
|
11 |
+
from transformers import pipeline
|
12 |
|
13 |
+
# load the model from the Hugging Face Model Hub
|
14 |
+
model = pipeline('image-classification', model='image_classification/densenet')
|
15 |
+
|
16 |
+
|
17 |
+
#model = tf.keras.models.load_model('/content/drive/MyDrive/project_image_2023_NO/saved_models/saved_model/densenet')
|
18 |
+
#labels = ['Healthy', 'Patient']
|
19 |
+
labels = {0: 'healthy', 1: 'patient'}
|
20 |
|
21 |
def classify_image(inp):
|
22 |
inp = inp.reshape((-1, 224, 224, 3))
|
|
|
25 |
confidences = {labels[i]: float(prediction[0][i]) for i in range(2)}
|
26 |
return confidences
|
27 |
|
28 |
+
|
29 |
gr.Interface(fn=classify_image,
|
30 |
inputs=gr.Image(shape=(224, 224)),
|
31 |
outputs=gr.Label(num_top_classes = 2),
|
32 |
title="Demo",
|
33 |
+
description="Here's a sample image classification. Enjoy!",
|
34 |
+
examples=[['path/to/example/image.jpg']]
|
35 |
).launch(share = True)
|