Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,6 +29,29 @@ def Get_Information(predicted_name):
|
|
| 29 |
return info_text
|
| 30 |
else:
|
| 31 |
return f"Không tìm thấy tệp 'information.text' trong thư mục của lớp '{class_name}'."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
# Tải mô hình
|
| 34 |
model = load_model('Model.keras')
|
|
@@ -88,5 +111,6 @@ if uploaded_file is not None or photo is not None:
|
|
| 88 |
|
| 89 |
st.write("`ID: " + str(predicted_label) + "`")
|
| 90 |
st.write("## Tên: " + predicted_class_name)
|
|
|
|
| 91 |
with st.expander("Xem thông tin chi tiết"):
|
| 92 |
st.markdown(Get_Information(predicted_class_name))
|
|
|
|
| 29 |
return info_text
|
| 30 |
else:
|
| 31 |
return f"Không tìm thấy tệp 'information.text' trong thư mục của lớp '{class_name}'."
|
| 32 |
+
|
| 33 |
+
def Get_Notes(predicted_name):
|
| 34 |
+
# Đường dẫn đến thư mục 'Dataset/Train'
|
| 35 |
+
train_dir = 'Dataset/Train'
|
| 36 |
+
|
| 37 |
+
# Duyệt qua mỗi lớp trong thư mục 'Dataset/Train'
|
| 38 |
+
for class_name in class_names:
|
| 39 |
+
# Nếu class_name không phải là predicted_name, tiếp tục vòng lặp
|
| 40 |
+
if class_name != predicted_name:
|
| 41 |
+
continue
|
| 42 |
+
|
| 43 |
+
# Đường dẫn đến tệp 'notes.info' trong thư mục của lớp
|
| 44 |
+
info_file_path = os.path.join(train_dir, class_name, 'notes.info')
|
| 45 |
+
|
| 46 |
+
# Kiểm tra xem tệp 'notes.info' có tồn tại không
|
| 47 |
+
if os.path.exists(info_file_path):
|
| 48 |
+
# Đọc nội dung của tệp
|
| 49 |
+
with open(info_file_path, 'r', encoding='utf-8') as f:
|
| 50 |
+
info_text = f.read()
|
| 51 |
+
|
| 52 |
+
return info_text
|
| 53 |
+
else:
|
| 54 |
+
return f"Không tìm thấy tệp 'notes.info' trong thư mục của lớp '{class_name}'."
|
| 55 |
|
| 56 |
# Tải mô hình
|
| 57 |
model = load_model('Model.keras')
|
|
|
|
| 111 |
|
| 112 |
st.write("`ID: " + str(predicted_label) + "`")
|
| 113 |
st.write("## Tên: " + predicted_class_name)
|
| 114 |
+
st.markdown(Get_Notes(predicted_class_name))
|
| 115 |
with st.expander("Xem thông tin chi tiết"):
|
| 116 |
st.markdown(Get_Information(predicted_class_name))
|