gauthamk commited on
Commit
b533667
1 Parent(s): b6c68a3

Change return dict value to float

Browse files
Files changed (2) hide show
  1. app.py +4 -2
  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(num_top_classes=2), cache_examples= False,
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': str(pred[0][0]), 'Substructure': str(pred[0][1])}
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