Dileep7729 commited on
Commit
45892bc
·
verified ·
1 Parent(s): 79a79b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -60,10 +60,10 @@ def classify_image(image):
60
  safe_prob = probs[0][0].item() * 100 # Safe percentage
61
  unsafe_prob = probs[0][1].item() * 100 # Unsafe percentage
62
 
63
- # Return results
64
  return {
65
- "safe": f"{safe_prob:.2f}%",
66
- "unsafe": f"{unsafe_prob:.2f}%"
67
  }
68
 
69
  except Exception as e:
@@ -74,7 +74,7 @@ def classify_image(image):
74
  iface = gr.Interface(
75
  fn=classify_image,
76
  inputs=gr.Image(type="pil"),
77
- outputs=gr.Text(label="Output"),
78
  title="Content Safety Classification",
79
  description="Upload an image to classify it as 'safe' or 'unsafe' with corresponding probabilities.",
80
  )
@@ -117,5 +117,6 @@ if __name__ == "__main__":
117
 
118
 
119
 
 
120
 
121
 
 
60
  safe_prob = probs[0][0].item() * 100 # Safe percentage
61
  unsafe_prob = probs[0][1].item() * 100 # Unsafe percentage
62
 
63
+ # Format data for visualization
64
  return {
65
+ "safe": safe_prob,
66
+ "unsafe": unsafe_prob
67
  }
68
 
69
  except Exception as e:
 
74
  iface = gr.Interface(
75
  fn=classify_image,
76
  inputs=gr.Image(type="pil"),
77
+ outputs=gr.Label(num_top_classes=2), # Use gr.Label to display probabilities with a bar-style visualization
78
  title="Content Safety Classification",
79
  description="Upload an image to classify it as 'safe' or 'unsafe' with corresponding probabilities.",
80
  )
 
117
 
118
 
119
 
120
+
121
 
122