talktorhutika commited on
Commit
a1e2c30
·
verified ·
1 Parent(s): 9461476

Update finetune3.py

Browse files
Files changed (1) hide show
  1. finetune3.py +6 -26
finetune3.py CHANGED
@@ -96,7 +96,7 @@ def main():
96
  # Show training data
97
  st.subheader("Training Data")
98
  train_df = pd.DataFrame({
99
- 'input_ids': [ids[:10] for ids in train_dataset['input_ids'][:5]], # Show first 10 tokens for brevity
100
  'attention_mask': [mask[:10] for mask in train_dataset['attention_mask'][:5]],
101
  'labels': train_dataset['labels'][:5]
102
  })
@@ -133,33 +133,13 @@ def main():
133
  st.subheader("Pretrained Model")
134
  if st.button('Show Pretrained Model'):
135
  if os.path.exists(model_dir):
136
- files = os.listdir(model_dir)
137
- st.write("Contents of `./finetuned_model` directory:")
138
  for file in files:
139
  file_path = os.path.join(model_dir, file)
140
- if os.path.isfile(file_path):
141
- st.write(f"- {file}")
142
- else:
143
- st.write(f"- [DIR] {file}")
144
- else:
145
- st.write("Directory `./finetuned_model` does not exist.")
146
-
147
- # Show the file content of model files (e.g., config.json, pytorch_model.bin)
148
- st.subheader("Model File Contents")
149
- if st.button('Show Model File Contents'):
150
- if os.path.exists(model_dir):
151
- files = os.listdir(model_dir)
152
- for file in files:
153
- file_path = os.path.join(model_dir, file)
154
- if os.path.isfile(file_path):
155
- if file_path.endswith(".txt") or file_path.endswith(".json"): # Handle text and JSON files
156
- st.write(f"**{file}:**")
157
- with open(file_path, 'r', encoding='utf-8', errors='ignore') as f:
158
- st.write(f.read())
159
- else:
160
- st.write(f"**{file}:** Binary file (not displayed)")
161
- else:
162
- st.write(f"**{file}:** [Directory - Contents not displayed]")
163
  else:
164
  st.write("Directory `./finetuned_model` does not exist.")
165
 
 
96
  # Show training data
97
  st.subheader("Training Data")
98
  train_df = pd.DataFrame({
99
+ 'input_ids': [ids[:10] for ids in train_dataset['input_ids'][:5]],
100
  'attention_mask': [mask[:10] for mask in train_dataset['attention_mask'][:5]],
101
  'labels': train_dataset['labels'][:5]
102
  })
 
133
  st.subheader("Pretrained Model")
134
  if st.button('Show Pretrained Model'):
135
  if os.path.exists(model_dir):
136
+ files = [f for f in os.listdir(model_dir) if f.endswith('.json')]
137
+ st.write("Contents of `.json` files in `./finetuned_model` directory:")
138
  for file in files:
139
  file_path = os.path.join(model_dir, file)
140
+ st.write(f"**{file}:**")
141
+ with open(file_path, 'r', encoding='utf-8') as f:
142
+ st.write(f.read())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  else:
144
  st.write("Directory `./finetuned_model` does not exist.")
145