trigger166 commited on
Commit
12ddec0
·
1 Parent(s): 9242c1b
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -46,14 +46,15 @@ training_args = TrainingArguments(
46
  )
47
 
48
  # Inizializza il Trainer
49
- trainer = Trainer(
50
- model=model,
51
- args=training_args,
52
- train_dataset=tokenized_dataset["train"]
53
- )
54
-
55
- trainer.train()
56
- trainer.push_to_hub("testA")
 
57
 
58
  def answer_question(question):
59
  inputs = tokenizer(question, return_tensors="pt", truncation=True, max_length=128).to(device)
@@ -62,4 +63,8 @@ def answer_question(question):
62
  return answer
63
 
64
  iface = gr.Interface(fn=answer_question, inputs="text", outputs="text")
 
 
 
 
65
  iface.launch()
 
46
  )
47
 
48
  # Inizializza il Trainer
49
+ def start_training():
50
+ trainer = Trainer(
51
+ model=model,
52
+ args=training_args,
53
+ train_dataset=tokenized_dataset["train"]
54
+ )
55
+ trainer.train()
56
+ trainer.push_to_hub("to_validate_model")
57
+ return "Training completato e caricato"
58
 
59
  def answer_question(question):
60
  inputs = tokenizer(question, return_tensors="pt", truncation=True, max_length=128).to(device)
 
63
  return answer
64
 
65
  iface = gr.Interface(fn=answer_question, inputs="text", outputs="text")
66
+ train_interface = gr.Interface(fn=start_training, inputs=[], outputs="text")
67
+ app = gr.TabbedInterface([iface, train_interface], ["Q&A", "Avvia Training"])
68
+
69
+
70
  iface.launch()