-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
יצירת גרסת cli של התוכנה שמשלבת זיהוי סוג מחרוזת (זמר או אחר) לצורך שכבת זיהוי נוספת על מודל ה-NER
- Loading branch information
Showing
3 changed files
with
85 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
machine-learn/music_classification/model_creation/try_model.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pickle | ||
|
||
# מיפוי תוויות מספריות לשמות קטגוריות | ||
label_mapping = {0: "ARTIST", 1: "ALBUM", 2: "SONG", 3: "RANDOM"} | ||
|
||
# טעינת המודל | ||
with open('music_classifier.pkl', 'rb') as f: | ||
loaded_model = pickle.load(f) | ||
|
||
# פונקציה לחיזוי על מחרוזת טקסט בודדת | ||
def classify_text(text): | ||
# המודל מצפה לקבל רשימה של טקסטים גם אם יש טקסט אחד בלבד | ||
prediction = loaded_model.predict([text]) | ||
return prediction[0] # החיזוי הוא רשימה ולכן אנו מחזירים את הערך הראשון | ||
|
||
# הדגמת השימוש בפונקציה | ||
text_input = input("הכנס מחרוזת טקסט לסיווג: ") | ||
prediction = classify_text(text_input) | ||
|
||
# הצגת התוצאה | ||
print(f"הקטגוריה של הטקסט היא: {label_mapping[prediction]} (זיהוי מספרי: {prediction})") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters