0llheaven commited on
Commit
ca01a23
·
verified ·
1 Parent(s): 97289f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -34,12 +34,9 @@ def detect_objects(image):
34
  draw.rectangle(box, outline="red", width=3)
35
  draw.text((box[0], box[1]), f"{label_name}: {round(score.item(), 3)}", fill="red")
36
 
37
- # แปลงภาพเป็นรูปแบบที่สามารถแสดงผลได้ใน Gradio
38
- output_image = io.BytesIO()
39
- image.save(output_image, format='PNG')
40
- output_image.seek(0)
41
-
42
- return output_image
43
 
44
  # สร้างอินเตอร์เฟซด้วย Gradio
45
  interface = gr.Interface(
 
34
  draw.rectangle(box, outline="red", width=3)
35
  draw.text((box[0], box[1]), f"{label_name}: {round(score.item(), 3)}", fill="red")
36
 
37
+ # แปลงภาพกลับเป็นรูปแบบที่ Gradio สามารถแสดงได้
38
+ pil_image = Image.fromarray(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
39
+ return pil_imag
 
 
 
40
 
41
  # สร้างอินเตอร์เฟซด้วย Gradio
42
  interface = gr.Interface(