DHEIVER commited on
Commit
5c1666a
1 Parent(s): 8c26c12

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -40,20 +40,24 @@ def classify_image(input_image):
40
  output_image = (input_image[0] * 255).astype('uint8')
41
  output_image_with_box = output_image.copy()
42
 
43
- # Desenhe uma caixa de identifica莽茫o de objeto no output_image_with_box (centralizada)
44
  if predicted_class == "Cataract": # Adicione sua l贸gica para desenhar a caixa com base na classe
45
  image_height, image_width, _ = output_image.shape
46
- box_size = min(image_height, image_width) // 3
47
  x1 = (image_width - box_size) // 2
48
  y1 = (image_height - box_size) // 2
49
  x2 = x1 + box_size
50
  y2 = y1 + box_size
51
  cv2.rectangle(output_image_with_box, (x1, y1), (x2, y2), (0, 255, 0), 2) # Caixa verde
52
 
53
- # Escreva o r贸tulo de previs茫o no output_image_with_box (com a cor da caixa)
54
  font = cv2.FONT_HERSHEY_SIMPLEX
55
  cv2.putText(output_image_with_box, f"Predicted Class: {predicted_class}", (10, 20), font, 0.5, (0, 255, 0), 2) # Cor verde
56
 
 
 
 
 
57
  return output_image_with_box
58
 
59
  # Crie uma interface Gradio
 
40
  output_image = (input_image[0] * 255).astype('uint8')
41
  output_image_with_box = output_image.copy()
42
 
43
+ # Desenhe uma caixa de identifica莽茫o de objeto no output_image_with_box (centralizada e maior)
44
  if predicted_class == "Cataract": # Adicione sua l贸gica para desenhar a caixa com base na classe
45
  image_height, image_width, _ = output_image.shape
46
+ box_size = min(image_height, image_width) // 2
47
  x1 = (image_width - box_size) // 2
48
  y1 = (image_height - box_size) // 2
49
  x2 = x1 + box_size
50
  y2 = y1 + box_size
51
  cv2.rectangle(output_image_with_box, (x1, y1), (x2, y2), (0, 255, 0), 2) # Caixa verde
52
 
53
+ # Escreva o r贸tulo de previs茫o no output_image_with_box (com a cor da caixa e estat铆sticas)
54
  font = cv2.FONT_HERSHEY_SIMPLEX
55
  cv2.putText(output_image_with_box, f"Predicted Class: {predicted_class}", (10, 20), font, 0.5, (0, 255, 0), 2) # Cor verde
56
 
57
+ # Adicione estat铆sticas (substitua com suas pr贸prias estat铆sticas)
58
+ stats = f"Accuracy: {prediction[0][class_index]:.2f}, Confidence: {prediction[0].max():.2f}"
59
+ cv2.putText(output_image_with_box, stats, (10, 40), font, 0.5, (0, 255, 0), 2)
60
+
61
  return output_image_with_box
62
 
63
  # Crie uma interface Gradio