Sakalti commited on
Commit
172f090
·
verified ·
1 Parent(s): 1bf4dfb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -42,8 +42,14 @@ def train_and_deploy(write_token, repo_name, license_text):
42
  print(f"Dataset keys: {dataset.keys()}")
43
  if "train" not in dataset:
44
  raise KeyError("The dataset does not contain a 'train' split.")
 
 
45
  if "test" not in dataset:
46
- raise KeyError("The dataset does not contain a 'test' split.")
 
 
 
 
47
 
48
  # データセットの最初のエントリのキーを確認
49
  print(f"Sample keys in 'train' split: {dataset['train'][0].keys()}")
@@ -139,9 +145,9 @@ with gr.Blocks() as demo:
139
 
140
  def update_ui():
141
  global progress_info
142
- status.update(value=progress_info["status"])
143
  progress.update(value=progress_info["progress"])
144
- time_remaining.update(value=f"{progress_info['time_remaining']}秒" if progress_info['time_remaining'] else "待機中")
145
 
146
  train_button.click(fn=train_and_deploy, inputs=[token_input, repo_input, license_input], outputs=output).then(fn=update_ui)
147
 
 
42
  print(f"Dataset keys: {dataset.keys()}")
43
  if "train" not in dataset:
44
  raise KeyError("The dataset does not contain a 'train' split.")
45
+
46
+ # testセットが存在しない場合、trainセットを分割してtestセットを作成
47
  if "test" not in dataset:
48
+ dataset = dataset["train"].train_test_split(test_size=0.1)
49
+ dataset = DatasetDict({
50
+ "train": dataset["train"],
51
+ "test": dataset["test"]
52
+ })
53
 
54
  # データセットの最初のエントリのキーを確認
55
  print(f"Sample keys in 'train' split: {dataset['train'][0].keys()}")
 
145
 
146
  def update_ui():
147
  global progress_info
148
+ status.value = progress_info["status"]
149
  progress.update(value=progress_info["progress"])
150
+ time_remaining.value = f"{progress_info['time_remaining']}秒" if progress_info['time_remaining'] else "待機中"
151
 
152
  train_button.click(fn=train_and_deploy, inputs=[token_input, repo_input, license_input], outputs=output).then(fn=update_ui)
153