Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -257,15 +257,14 @@ class AITrainerApp:
|
|
257 |
total_texts = []
|
258 |
for file_info in files:
|
259 |
try:
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
self.output_log = self.log_output(f"Loaded {len(chunks)} chunks from {os.path.basename(file_path)}")
|
267 |
except Exception as e:
|
268 |
-
error_msg = f"Error reading {
|
269 |
self.output_log = self.log_output(error_msg)
|
270 |
return error_msg, self.output_log
|
271 |
|
@@ -300,8 +299,9 @@ class AITrainerApp:
|
|
300 |
|
301 |
def start_training(self, d_model, n_layers, n_heads, batch_size, learning_rate, epochs, device_type):
|
302 |
if not self.training_data:
|
303 |
-
|
304 |
-
|
|
|
305 |
|
306 |
self.stop_training_flag = False
|
307 |
self.training_status = "Training started..."
|
|
|
257 |
total_texts = []
|
258 |
for file_info in files:
|
259 |
try:
|
260 |
+
# Read the content from the file object
|
261 |
+
content = file_info.read().decode('utf-8')
|
262 |
+
# Split into smaller chunks if needed
|
263 |
+
chunks = self.split_into_chunks(content, 1000)
|
264 |
+
total_texts.extend(chunks)
|
265 |
+
self.output_log = self.log_output(f"Loaded {len(chunks)} chunks from {file_info.name}")
|
|
|
266 |
except Exception as e:
|
267 |
+
error_msg = f"Error reading {file_info.name}: {str(e)}"
|
268 |
self.output_log = self.log_output(error_msg)
|
269 |
return error_msg, self.output_log
|
270 |
|
|
|
299 |
|
300 |
def start_training(self, d_model, n_layers, n_heads, batch_size, learning_rate, epochs, device_type):
|
301 |
if not self.training_data:
|
302 |
+
error_msg = "Error: No training data loaded!"
|
303 |
+
self.output_log = self.log_output(error_msg)
|
304 |
+
return error_msg, self.output_log, gr.update(interactive=True)
|
305 |
|
306 |
self.stop_training_flag = False
|
307 |
self.training_status = "Training started..."
|