kkandull commited on
Commit
5cff552
ยท
verified ยท
1 Parent(s): c32e434

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -10
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
- # ๋ชจ๋ธ ๊ฐ€์ค‘์น˜๊ฐ€ ์ €์žฅ๋œ ๋””๋ ‰ํ† ๋ฆฌ (Hugging Face Spaces์— ์—…๋กœ๋“œํ•  ๋•Œ ์ƒ์„ฑํ•  ํด๋”)
66
- save_dir = "saved_models"
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.")