Update app.py
Browse files
app.py
CHANGED
|
@@ -63,19 +63,23 @@ def enhanced_validation(tokenizer, test_text):
|
|
| 63 |
"token_length_distribution": img_buffer.getvalue()
|
| 64 |
}
|
| 65 |
|
|
|
|
|
|
|
| 66 |
def train_and_test(files, dataset_name, split, vocab_size, min_freq, test_text):
|
| 67 |
-
"""
|
| 68 |
-
Συνδυάζει τη διαδικασία εκπαίδευσης του tokenizer και την επικύρωση του με ένα δοκιμαστικό κείμενο.
|
| 69 |
-
"""
|
| 70 |
-
# Επιβεβαίωση εισόδων: πρέπει να παρέχεται είτε αρχείο είτε όνομα dataset
|
| 71 |
if not files and not dataset_name:
|
| 72 |
raise gr.Error("Πρέπει να παρέχετε αρχεία ή όνομα dataset!")
|
| 73 |
|
| 74 |
-
# Δημιουργία iterator (με streaming για αποδοτική ανάγνωση)
|
| 75 |
-
iterator = create_iterator(files, dataset_name, split)
|
| 76 |
-
|
| 77 |
try:
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
except Exception as e:
|
| 80 |
raise gr.Error(f"Σφάλμα εκπαίδευσης: {str(e)}")
|
| 81 |
|
|
|
|
| 63 |
"token_length_distribution": img_buffer.getvalue()
|
| 64 |
}
|
| 65 |
|
| 66 |
+
# ... (προηγούμενο imports και functions παραμένουν ίδια)
|
| 67 |
+
|
| 68 |
def train_and_test(files, dataset_name, split, vocab_size, min_freq, test_text):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
if not files and not dataset_name:
|
| 70 |
raise gr.Error("Πρέπει να παρέχετε αρχεία ή όνομα dataset!")
|
| 71 |
|
|
|
|
|
|
|
|
|
|
| 72 |
try:
|
| 73 |
+
# Δημιουργία iterator με fallback
|
| 74 |
+
iterator = create_iterator(files, dataset_name, split)
|
| 75 |
+
|
| 76 |
+
# Προσθήκη progress bar
|
| 77 |
+
with gr.Progress() as progress:
|
| 78 |
+
progress(0.1, desc="Προεπεξεργασία δεδομένων...")
|
| 79 |
+
tokenizer = train_tokenizer(iterator, vocab_size, min_freq)
|
| 80 |
+
|
| 81 |
+
# ... (υπόλοιπη λειτουργία παραμένει ίδια)
|
| 82 |
+
|
| 83 |
except Exception as e:
|
| 84 |
raise gr.Error(f"Σφάλμα εκπαίδευσης: {str(e)}")
|
| 85 |
|