suryaprakash01 commited on
Commit
b102658
·
verified ·
1 Parent(s): e047e8b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -175,10 +175,13 @@ det_model = load_detection_model()
175
  st.subheader("Upload an image")
176
  uploaded = st.file_uploader("Choose JPG/PNG", type=["jpg", "jpeg", "png"])
177
 
178
- if uploaded is not None:
179
  try:
180
- file_bytes = uploaded.read()
181
- img = Image.open(io.BytesIO(file_bytes)).convert("RGB")
 
 
 
182
  img_np = np.array(img)
183
 
184
  st.image(img, caption="Uploaded Image", use_column_width=True)
 
175
  st.subheader("Upload an image")
176
  uploaded = st.file_uploader("Choose JPG/PNG", type=["jpg", "jpeg", "png"])
177
 
178
+ if uploaded:
179
  try:
180
+ # IMPORTANT: Do NOT use uploaded.read() directly.
181
+ # Instead, we manually convert to bytes.
182
+ raw_bytes = uploaded.getvalue() # <-- THIS bypasses HF upload pipeline
183
+
184
+ img = Image.open(io.BytesIO(raw_bytes)).convert("RGB")
185
  img_np = np.array(img)
186
 
187
  st.image(img, caption="Uploaded Image", use_column_width=True)