for876543 commited on
Commit
22483c5
1 Parent(s): deae187

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -3,6 +3,7 @@ import torch
3
  import torch.nn.functional as nnf
4
  import gradio as gr
5
  import numpy as np
 
6
  import json
7
 
8
 
@@ -25,9 +26,9 @@ classes.sort()
25
  labels = classes
26
 
27
  def classify_image(inp):
28
- print(inp.shape)
29
  inp = inp.astype(np.uint8).reshape((-1, 3, 300, 300))
30
- print(inp.shape)
31
  inp = torch.from_numpy(inp).float()
32
  #confidences = model(inp)
33
 
@@ -39,6 +40,7 @@ def classify_image(inp):
39
  preds = nnf.softmax(preds, dim=0)
40
  preds = [pred.cpu() for pred in preds]
41
  preds = [float(pred.detach()) for pred in preds]
 
42
 
43
  #confidences_dict = {classes[i]: float(confidences.data[0][i]) for i in range(len(confidences.data[0]))}
44
  confidences_dict = {classes[i]: float(preds[i]) for i in range(len(preds))}
 
3
  import torch.nn.functional as nnf
4
  import gradio as gr
5
  import numpy as np
6
+ import pandas as pd
7
  import json
8
 
9
 
 
26
  labels = classes
27
 
28
  def classify_image(inp):
29
+ #print(inp.shape)
30
  inp = inp.astype(np.uint8).reshape((-1, 3, 300, 300))
31
+ #print(inp.shape)
32
  inp = torch.from_numpy(inp).float()
33
  #confidences = model(inp)
34
 
 
40
  preds = nnf.softmax(preds, dim=0)
41
  preds = [pred.cpu() for pred in preds]
42
  preds = [float(pred.detach()) for pred in preds]
43
+ print(pd.Series(preds).describe())
44
 
45
  #confidences_dict = {classes[i]: float(confidences.data[0][i]) for i in range(len(confidences.data[0]))}
46
  confidences_dict = {classes[i]: float(preds[i]) for i in range(len(preds))}