krishnamishra8848 commited on
Commit
e50eca6
·
verified ·
1 Parent(s): 80caae0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -27,7 +27,7 @@ def detect_license_plate(image):
27
  for box, conf in zip(result.boxes.xyxy, result.boxes.conf):
28
  x1, y1, x2, y2 = map(int, box) # Convert to integers
29
  cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2) # Green rectangle
30
- label = f"Confidence: {conf:.2f}"
31
  cv2.putText(img, label, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
32
 
33
  # Convert back to RGB for Streamlit display
@@ -42,13 +42,10 @@ st.write("Upload an image to detect license plates.")
42
  uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
43
 
44
  if uploaded_file is not None:
45
- # Display the uploaded image
46
- image = Image.open(uploaded_file)
47
- st.image(image, caption="Uploaded Image", use_column_width=True)
48
-
49
- # Run detection
50
  st.write("Processing...")
 
51
  result_image = detect_license_plate(image)
52
 
53
- # Display the results
54
- st.image(result_image, caption="Detection Results", use_column_width=True)
 
27
  for box, conf in zip(result.boxes.xyxy, result.boxes.conf):
28
  x1, y1, x2, y2 = map(int, box) # Convert to integers
29
  cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2) # Green rectangle
30
+ label = f"{conf:.2f}"
31
  cv2.putText(img, label, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
32
 
33
  # Convert back to RGB for Streamlit display
 
42
  uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
43
 
44
  if uploaded_file is not None:
45
+ # Run detection directly after uploading
 
 
 
 
46
  st.write("Processing...")
47
+ image = Image.open(uploaded_file)
48
  result_image = detect_license_plate(image)
49
 
50
+ # Display the detection result
51
+ st.image(result_image, caption="Detection Results", use_container_width=True)