Update app.py
Browse files
app.py
CHANGED
@@ -103,11 +103,26 @@ def sepia(input_img):
|
|
103 |
|
104 |
custom_template = "my_custom_template.html"
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
demo = gr.Interface(fn=sepia,
|
107 |
inputs=gr.Image(shape=(400, 600)),
|
108 |
outputs=['plot'],
|
109 |
title="SWJIN11 TASK",
|
110 |
description="경제학과 202211357 진성원",
|
|
|
111 |
examples=["ADE_val_00000001.jpeg", "ADE_val_00001248.jpg", "image1.jpg", "image2.jpg", "image3.jpg", "image4.jpg"],
|
112 |
allow_flagging='never')
|
113 |
|
|
|
103 |
|
104 |
custom_template = "my_custom_template.html"
|
105 |
|
106 |
+
def explain_prediction(input_img):
|
107 |
+
# 모델 예측 수행
|
108 |
+
prediction = my_model.predict(input_img)
|
109 |
+
|
110 |
+
# 예측 결과를 설명하는 텍스트 생성
|
111 |
+
explanation = f"The model predicts this image as class {prediction}."
|
112 |
+
|
113 |
+
# 시각화: 예측 설명 텍스트를 이미지에 표시
|
114 |
+
result_image = input_img.copy()
|
115 |
+
cv2.putText(result_image, explanation, (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
|
116 |
+
|
117 |
+
return result_image
|
118 |
+
|
119 |
+
|
120 |
demo = gr.Interface(fn=sepia,
|
121 |
inputs=gr.Image(shape=(400, 600)),
|
122 |
outputs=['plot'],
|
123 |
title="SWJIN11 TASK",
|
124 |
description="경제학과 202211357 진성원",
|
125 |
+
interpretation="default",
|
126 |
examples=["ADE_val_00000001.jpeg", "ADE_val_00001248.jpg", "image1.jpg", "image2.jpg", "image3.jpg", "image4.jpg"],
|
127 |
allow_flagging='never')
|
128 |
|