yuragoithf commited on
Commit
a3cd4d1
1 Parent(s): 334672e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -51,24 +51,24 @@ def predict_class(image):
51
  return prediction[0]
52
 
53
  # UI Design for single class output
54
- # def classify_image(image):
55
- # predicted_class = predict_class(image)
56
- # output = f"<h2>Predicted Class: <span style='text-transform:uppercase';>{predicted_class}</span></h2>"
57
- # return output
58
 
59
 
60
  # UI Design for multy class output
61
- def classify_image(image):
62
- results = predict_class(image)
63
- print(results)
64
- output = {labels.get(i): float(results[i]) for i in range(len(results))}
65
- result = output if max(output.values()) >=0.98 else {"NO_CIFAR10_CLASS": 1}
66
- return result
67
 
68
 
69
  inputs = gr.inputs.Image(type="pil", label="Upload an image")
70
- # outputs = gr.outputs.HTML() #uncomment for single class output
71
- outputs = gr.outputs.Label(num_top_classes=4)
72
 
73
  title = "<h1 style='text-align: center;'>Image Classifier</h1>"
74
  description = "Upload an image and get the predicted class."
 
51
  return prediction[0]
52
 
53
  # UI Design for single class output
54
+ def classify_image(image):
55
+ predicted_class = predict_class(image)
56
+ output = f"<h2>Predicted Class: <span style='text-transform:uppercase';>{predicted_class}</span></h2>"
57
+ return output
58
 
59
 
60
  # UI Design for multy class output
61
+ # def classify_image(image):
62
+ # results = predict_class(image)
63
+ # print(results)
64
+ # output = {labels.get(i): float(results[i]) for i in range(len(results))}
65
+ # result = output if max(output.values()) >=0.98 else {"NO_CIFAR10_CLASS": 1}
66
+ # return result
67
 
68
 
69
  inputs = gr.inputs.Image(type="pil", label="Upload an image")
70
+ outputs = gr.outputs.HTML() #uncomment for single class output
71
+ #outputs = gr.outputs.Label(num_top_classes=4)
72
 
73
  title = "<h1 style='text-align: center;'>Image Classifier</h1>"
74
  description = "Upload an image and get the predicted class."