Spaces:
Sleeping
Sleeping
Change return dict value to float
Browse files- app.py +4 -2
- functions.py +1 -1
app.py
CHANGED
@@ -2,17 +2,19 @@ import gradio as gr
|
|
2 |
import os
|
3 |
from functions import *
|
4 |
|
|
|
5 |
examples_dir = 'examples'
|
6 |
-
title = "CvT: Substructure Prediction"
|
7 |
|
|
|
8 |
examples = []
|
9 |
for root, dirs, files in os.walk(examples_dir):
|
10 |
for file in files:
|
11 |
if file.endswith(".jpg"):
|
12 |
examples.append([os.path.join(root, file), os.path.join(root, file)])
|
13 |
|
|
|
14 |
interface = gr.Interface(fn=predict, inputs=gr.Image(type= 'pil', shape=(256, 256), image_mode= 'L'),
|
15 |
-
outputs= gr.Label(
|
16 |
examples= examples, title= title, css= '.gr-box {background-color: rgb(230 230 230);}')
|
17 |
|
18 |
interface.launch()
|
|
|
2 |
import os
|
3 |
from functions import *
|
4 |
|
5 |
+
title = "DeepLense CvT: Substructure Prediction"
|
6 |
examples_dir = 'examples'
|
|
|
7 |
|
8 |
+
# loading the example files
|
9 |
examples = []
|
10 |
for root, dirs, files in os.walk(examples_dir):
|
11 |
for file in files:
|
12 |
if file.endswith(".jpg"):
|
13 |
examples.append([os.path.join(root, file), os.path.join(root, file)])
|
14 |
|
15 |
+
# initialising the interface
|
16 |
interface = gr.Interface(fn=predict, inputs=gr.Image(type= 'pil', shape=(256, 256), image_mode= 'L'),
|
17 |
+
outputs= gr.Label(), cache_examples= False,
|
18 |
examples= examples, title= title, css= '.gr-box {background-color: rgb(230 230 230);}')
|
19 |
|
20 |
interface.launch()
|
functions.py
CHANGED
@@ -14,5 +14,5 @@ def predict(img):
|
|
14 |
pred = session.run([output_name], {input_name: img})[0]
|
15 |
pred = np.exp(pred) / np.sum(np.exp(pred), axis=1, keepdims=True)
|
16 |
|
17 |
-
class_probs = {'No Substructure':
|
18 |
return class_probs
|
|
|
14 |
pred = session.run([output_name], {input_name: img})[0]
|
15 |
pred = np.exp(pred) / np.sum(np.exp(pred), axis=1, keepdims=True)
|
16 |
|
17 |
+
class_probs = {'No Substructure': float(pred[0][0]), 'Substructure': float(pred[0][1])}
|
18 |
return class_probs
|