Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
# ํ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ํฌํธ
|
2 |
import os
|
3 |
-
import pandas as pd
|
4 |
import numpy as np
|
5 |
import torch
|
6 |
import torch.nn as nn
|
@@ -62,12 +62,10 @@ class DepressionDataset(Dataset):
|
|
62 |
# =======================================================
|
63 |
print("\n--- Loading models for inference ---")
|
64 |
|
65 |
-
# ๋ชจ๋ธ
|
66 |
-
save_dir
|
67 |
-
|
68 |
-
#
|
69 |
-
p_model_path = os.path.join(save_dir, 'p_text_best_model.bin')
|
70 |
-
e_model_path = os.path.join(save_dir, 'e_text_best_model.bin')
|
71 |
|
72 |
# ๋ชจ๋ธ ๋ก๋ฉ ๋ฐ ํ๊ฐ ๋ชจ๋ ์ค์
|
73 |
p_model_for_inference = None
|
@@ -82,7 +80,7 @@ try:
|
|
82 |
p_model_for_inference.eval() # ํ๊ฐ ๋ชจ๋ ์ค์
|
83 |
print(f"P-model loaded successfully from {p_model_path}")
|
84 |
else:
|
85 |
-
print(f"Warning: P-model file not found at {p_model_path}. Please ensure it's uploaded.")
|
86 |
|
87 |
# ์๋ฆฌ ๋ฐํ ๋ชจ๋ธ (E-model) ๋ก๋
|
88 |
if os.path.exists(e_model_path):
|
@@ -92,7 +90,7 @@ try:
|
|
92 |
e_model_for_inference.eval() # ํ๊ฐ ๋ชจ๋ ์ค์
|
93 |
print(f"E-model loaded successfully from {e_model_path}")
|
94 |
else:
|
95 |
-
print(f"Warning: E-model file not found at {e_model_path}. Please ensure it's uploaded.")
|
96 |
|
97 |
except Exception as e:
|
98 |
print(f"Error loading models: {e}")
|
@@ -193,4 +191,3 @@ if p_model_for_inference is not None and e_model_for_inference is not None:
|
|
193 |
).launch() # Hugging Face Spaces์์๋ share=True๊ฐ ํ์ ์์
|
194 |
else:
|
195 |
print("\nGradio UI could not be launched because models failed to load. Please check model files.")
|
196 |
-
|
|
|
1 |
# ํ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ํฌํธ
|
2 |
import os
|
3 |
+
import pandas as pd # pandas๋ ํ์ฌ ์ฝ๋์์๋ ์ง์ ์ฌ์ฉ๋์ง ์์ง๋ง, ๋ฐ์ดํฐ ์ฒ๋ฆฌ ๊ด๋ จ ์ ํธ๋ฆฌํฐ๋ก ๋จ๊ฒจ๋ ์ ์์ต๋๋ค.
|
4 |
import numpy as np
|
5 |
import torch
|
6 |
import torch.nn as nn
|
|
|
62 |
# =======================================================
|
63 |
print("\n--- Loading models for inference ---")
|
64 |
|
65 |
+
# ๋ชจ๋ธ ํ์ผ ๊ฒฝ๋ก (saved_models ํด๋๊ฐ ์์ผ๋ฏ๋ก ๋ฃจํธ ๋๋ ํ ๋ฆฌ์ ์๋ค๊ณ ๊ฐ์ )
|
66 |
+
# ์ด์ ์ ์๋ save_dir ๋ณ์๋ ์ด์ ํ์ ์์ต๋๋ค.
|
67 |
+
p_model_path = 'p_text_best_model.bin' # ํ์ผ๋ช
์ด ๋ฃจํธ์ ๋ฐ๋ก ์๋ค๊ณ ๊ฐ์
|
68 |
+
e_model_path = 'e_text_best_model.bin' # ํ์ผ๋ช
์ด ๋ฃจํธ์ ๋ฐ๋ก ์๋ค๊ณ ๊ฐ์
|
|
|
|
|
69 |
|
70 |
# ๋ชจ๋ธ ๋ก๋ฉ ๋ฐ ํ๊ฐ ๋ชจ๋ ์ค์
|
71 |
p_model_for_inference = None
|
|
|
80 |
p_model_for_inference.eval() # ํ๊ฐ ๋ชจ๋ ์ค์
|
81 |
print(f"P-model loaded successfully from {p_model_path}")
|
82 |
else:
|
83 |
+
print(f"Warning: P-model file not found at {p_model_path}. Please ensure it's uploaded to the root directory.")
|
84 |
|
85 |
# ์๋ฆฌ ๋ฐํ ๋ชจ๋ธ (E-model) ๋ก๋
|
86 |
if os.path.exists(e_model_path):
|
|
|
90 |
e_model_for_inference.eval() # ํ๊ฐ ๋ชจ๋ ์ค์
|
91 |
print(f"E-model loaded successfully from {e_model_path}")
|
92 |
else:
|
93 |
+
print(f"Warning: E-model file not found at {e_model_path}. Please ensure it's uploaded to the root directory.")
|
94 |
|
95 |
except Exception as e:
|
96 |
print(f"Error loading models: {e}")
|
|
|
191 |
).launch() # Hugging Face Spaces์์๋ share=True๊ฐ ํ์ ์์
|
192 |
else:
|
193 |
print("\nGradio UI could not be launched because models failed to load. Please check model files.")
|
|