Suphawan commited on
Commit
ca860a0
·
verified ·
1 Parent(s): f469d75

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -18,18 +18,17 @@ def predict(img):
18
  img_array = preprocess_input(img_array) # เตรียมรูปภาพให้สอดคล้องกับความต้องการของโมเดล
19
 
20
  predictions = model.predict(img_array)
21
- class_idx = np.argmax(predictions, axis=1)[0]
22
- class_label = class_names[class_idx] # ใช้ชื่อคลาสที่คุณประกาศไว้
23
- confidence = predictions[0][class_idx]
24
 
25
- return {class_label: float(confidence)}
26
 
27
  # สร้าง Gradio Interface
28
  interface = gr.Interface(
29
  fn=predict,
30
  inputs=gr.Image(type="pil", label="Upload an Image"),
31
  outputs=gr.Label(num_top_classes=2, label="Predicted Class"),
32
- title="Image Classification with InceptionV3",
33
  description="Upload an image to classify it into one of the classes."
34
  )
35
 
 
18
  img_array = preprocess_input(img_array) # เตรียมรูปภาพให้สอดคล้องกับความต้องการของโมเดล
19
 
20
  predictions = model.predict(img_array)
21
+ predictions = predictions[0] # เอาค่าผลลัพธ์ของ batch เดียว
22
+ confidence_dict = {class_names[i]: float(predictions[i]) for i in range(len(class_names))}
 
23
 
24
+ return confidence_dict
25
 
26
  # สร้าง Gradio Interface
27
  interface = gr.Interface(
28
  fn=predict,
29
  inputs=gr.Image(type="pil", label="Upload an Image"),
30
  outputs=gr.Label(num_top_classes=2, label="Predicted Class"),
31
+ title="Melanoma Classification with InceptionV3",
32
  description="Upload an image to classify it into one of the classes."
33
  )
34