Spaces:
Sleeping
Sleeping
mochuan zhan
commited on
Commit
·
a2ce9c9
1
Parent(s):
455f3a3
fix + 3
Browse files
app.py
CHANGED
|
@@ -80,8 +80,11 @@ transform = transforms.Compose([
|
|
| 80 |
|
| 81 |
# 定义预测函数
|
| 82 |
def classify_image(image):
|
| 83 |
-
#
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
| 85 |
if not isinstance(image, Image.Image):
|
| 86 |
raise TypeError(f"Expected image to be PIL Image, but got {type(image)}")
|
| 87 |
|
|
@@ -109,7 +112,6 @@ def classify_image(image):
|
|
| 109 |
# 返回结果字典,包含预测类别和置信度
|
| 110 |
return {str(predicted.item()): confidence}
|
| 111 |
|
| 112 |
-
|
| 113 |
# # 创建Gradio界面
|
| 114 |
# iface = gr.Interface(
|
| 115 |
# fn=classify_image,
|
|
|
|
| 80 |
|
| 81 |
# 定义预测函数
|
| 82 |
def classify_image(image):
|
| 83 |
+
# 检查是否包含 'composite' 数据
|
| 84 |
+
if isinstance(image, dict) and 'composite' in image:
|
| 85 |
+
image = image['composite']
|
| 86 |
+
|
| 87 |
+
# 确保 image 是一个 PIL 图像
|
| 88 |
if not isinstance(image, Image.Image):
|
| 89 |
raise TypeError(f"Expected image to be PIL Image, but got {type(image)}")
|
| 90 |
|
|
|
|
| 112 |
# 返回结果字典,包含预测类别和置信度
|
| 113 |
return {str(predicted.item()): confidence}
|
| 114 |
|
|
|
|
| 115 |
# # 创建Gradio界面
|
| 116 |
# iface = gr.Interface(
|
| 117 |
# fn=classify_image,
|