idkWhatToUse commited on
Commit
da9b217
·
verified ·
1 Parent(s): 50862fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -5,7 +5,7 @@ import json
5
  import clip
6
  from transformers import AutoTokenizer, AutoModelForCausalLM
7
  from huggingface_hub import hf_hub_download
8
-
9
  # =========================================================
10
  # 1. 讀取台南垃圾分類資料庫 JSON
11
  # =========================================================
@@ -88,6 +88,9 @@ def classify_clip(image, obj_name):
88
  # 5. 主流程:物件偵測 → 查資料庫 → 顯示官方資訊
89
  # =========================================================
90
  def pipeline(image):
 
 
 
91
  image.save("temp.jpg")
92
 
93
  # 1. GroundingDINO 偵測物品
 
5
  import clip
6
  from transformers import AutoTokenizer, AutoModelForCausalLM
7
  from huggingface_hub import hf_hub_download
8
+ import numpy as np
9
  # =========================================================
10
  # 1. 讀取台南垃圾分類資料庫 JSON
11
  # =========================================================
 
88
  # 5. 主流程:物件偵測 → 查資料庫 → 顯示官方資訊
89
  # =========================================================
90
  def pipeline(image):
91
+ # Gradio 會回傳 numpy array,因此先轉換
92
+ if isinstance(image, np.ndarray):
93
+ image = Image.fromarray(image.astype("uint8"))
94
  image.save("temp.jpg")
95
 
96
  # 1. GroundingDINO 偵測物品