Update script files
Browse files- src/predict.py +11 -2
src/predict.py
CHANGED
|
@@ -8,6 +8,7 @@ import pandas as pd
|
|
| 8 |
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 9 |
|
| 10 |
from src.utils import read_binary_file
|
|
|
|
| 11 |
|
| 12 |
def predict_file(model_path, file_path, max_length=2_000_000): # 2,000,000
|
| 13 |
"""
|
|
@@ -22,7 +23,11 @@ def predict_file(model_path, file_path, max_length=2_000_000): # 2,000,000
|
|
| 22 |
float: ์์ธก ํ๋ฅ (0์ ๊ฐ๊น์ฐ๋ฉด ์
์ฑ์ฝ๋, 1์ ๊ฐ๊น์ฐ๋ฉด ์ ์)
|
| 23 |
"""
|
| 24 |
# ๋ชจ๋ธ ๋ก๋
|
| 25 |
-
model =
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
# ํ์ผ ์ฝ๊ธฐ
|
| 28 |
byte_array = read_binary_file(file_path, max_length)
|
|
@@ -47,7 +52,11 @@ def predict_batch(model_path, csv_path, output_path=None, max_length=2**20):
|
|
| 47 |
"""
|
| 48 |
# ๋ชจ๋ธ ๋ก๋
|
| 49 |
print("๋ชจ๋ธ ๋ก๋ฉ ์ค...")
|
| 50 |
-
model =
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
# CSV ํ์ผ ์ฝ๊ธฐ
|
| 53 |
df = pd.read_csv(csv_path)
|
|
|
|
| 8 |
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 9 |
|
| 10 |
from src.utils import read_binary_file
|
| 11 |
+
from src.model import MalConv
|
| 12 |
|
| 13 |
def predict_file(model_path, file_path, max_length=2_000_000): # 2,000,000
|
| 14 |
"""
|
|
|
|
| 23 |
float: ์์ธก ํ๋ฅ (0์ ๊ฐ๊น์ฐ๋ฉด ์
์ฑ์ฝ๋, 1์ ๊ฐ๊น์ฐ๋ฉด ์ ์)
|
| 24 |
"""
|
| 25 |
# ๋ชจ๋ธ ๋ก๋
|
| 26 |
+
model = MalConv(max_input_length=max_length)
|
| 27 |
+
# ๋ชจ๋ธ์ ๊ฐ์ค์น๋ฅผ ๋ก๋ํ๊ธฐ ์ ์ ๋น๋
|
| 28 |
+
dummy_input = tf.zeros((1, max_length), dtype=tf.int32)
|
| 29 |
+
model(dummy_input) # ๋ชจ๋ธ ๋น๋
|
| 30 |
+
model.load_weights(model_path)
|
| 31 |
|
| 32 |
# ํ์ผ ์ฝ๊ธฐ
|
| 33 |
byte_array = read_binary_file(file_path, max_length)
|
|
|
|
| 52 |
"""
|
| 53 |
# ๋ชจ๋ธ ๋ก๋
|
| 54 |
print("๋ชจ๋ธ ๋ก๋ฉ ์ค...")
|
| 55 |
+
model = MalConv(max_input_length=max_length)
|
| 56 |
+
# ๋ชจ๋ธ์ ๊ฐ์ค์น๋ฅผ ๋ก๋ํ๊ธฐ ์ ์ ๋น๋
|
| 57 |
+
dummy_input = tf.zeros((1, max_length), dtype=tf.int32)
|
| 58 |
+
model(dummy_input) # ๋ชจ๋ธ ๋น๋
|
| 59 |
+
model.load_weights(model_path)
|
| 60 |
|
| 61 |
# CSV ํ์ผ ์ฝ๊ธฐ
|
| 62 |
df = pd.read_csv(csv_path)
|