Upload folder using huggingface_hub
Browse filesFiles changed (7)
- forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/before/clock.txtAdded+9
- forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/before/transcript.jsonlAdded+9
- forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/clock.txtAdded+32
- forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/episode.jsonAdded+56
- forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/stderr.txtAdded
- forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/transcript.jsonlAdded
- forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/work/solution.pyAdded+237
1234567896.456.566.568.368.708.7312.6116.0316.03123456789{"type":"step_start","timestamp":1795317791016,"sessionID":"ses_dfeb89c4cffe8b04HBWj4aUxSo","part":{"id":"prt_201477917001vFqIxBy2lXs4bw","messageID":"msg_2014765a4001cmkGk0Q6EA4jhY","sessionID":"ses_dfeb89c4cffe8b04HBWj4aUxSo","type":"step-start"}}{"type":"tool_use","timestamp":1795317791125,"sessionID":"ses_dfeb89c4cffe8b04HBWj4aUxSo","part":{"type":"tool","tool":"glob","callID":"chatcmpl-tool-9021d7e205e4adeb","state":{"status":"completed","input":{"pattern":"**/*","path":"/home/ubuntu/.cache/styx/forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/before/work"},"output":"No files found","metadata":{"count":0,"truncated":false},"title":"home/ubuntu/.cache/styx/forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/before/work","time":{"start":1795317791012,"end":1795317791110}},"id":"prt_20147791e001THbLJ2Mk06Hkmk","sessionID":"ses_dfeb89c4cffe8b04HBWj4aUxSo","messageID":"msg_2014765a4001cmkGk0Q6EA4jhY"}}{"type":"step_finish","timestamp":1795317791125,"sessionID":"ses_dfeb89c4cffe8b04HBWj4aUxSo","part":{"id":"prt_20147798a001J9aflL0lfY7svj","reason":"tool-calls","messageID":"msg_2014765a4001cmkGk0Q6EA4jhY","sessionID":"ses_dfeb89c4cffe8b04HBWj4aUxSo","type":"step-finish","tokens":{"total":5378,"input":5274,"output":55,"reasoning":49,"cache":{"write":0,"read":0}},"cost":0}}{"type":"step_start","timestamp":1795317792920,"sessionID":"ses_dfeb89c4cffe8b04HBWj4aUxSo","part":{"id":"prt_201478094001SVbHJ72MliWF1x","messageID":"msg_2014779920016erkf4WDemwiPs","sessionID":"ses_dfeb89c4cffe8b04HBWj4aUxSo","type":"step-start"}}{"type":"tool_use","timestamp":1795317793264,"sessionID":"ses_dfeb89c4cffe8b04HBWj4aUxSo","part":{"type":"tool","tool":"read","callID":"chatcmpl-tool-aa1d0e7023f00c2a","state":{"status":"completed","input":{"filePath":"/home/ubuntu/.cache/styx/forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/before/work"},"output":"<path>/home/ubuntu/.cache/styx/forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/before/work</path>\n<type>directory</type>\n<entries>\n\n\n(0 entries)\n</entries>","metadata":{"preview":"","truncated":false,"loaded":[],"display":{"type":"directory","path":"/home/ubuntu/.cache/styx/forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/before/work","entries":[],"offset":1,"totalEntries":0,"truncated":false}},"title":"home/ubuntu/.cache/styx/forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/before/work","time":{"start":1795317793259,"end":1795317793262}},"id":"prt_20147815e001xgqrLLKFpuAtdE","sessionID":"ses_dfeb89c4cffe8b04HBWj4aUxSo","messageID":"msg_2014779920016erkf4WDemwiPs"}}{"type":"step_finish","timestamp":1795317793293,"sessionID":"ses_dfeb89c4cffe8b04HBWj4aUxSo","part":{"id":"prt_201478206001c8rNG10ak8kZGZ","reason":"tool-calls","messageID":"msg_2014779920016erkf4WDemwiPs","sessionID":"ses_dfeb89c4cffe8b04HBWj4aUxSo","type":"step-finish","tokens":{"total":5453,"input":271,"output":49,"reasoning":13,"cache":{"write":0,"read":5120}},"cost":0}}{"type":"step_start","timestamp":1795317797177,"sessionID":"ses_dfeb89c4cffe8b04HBWj4aUxSo","part":{"id":"prt_201479135001IztLCOFRSk1ov3","messageID":"msg_20147820b001gHLqRvEH7bNrAN","sessionID":"ses_dfeb89c4cffe8b04HBWj4aUxSo","type":"step-start"}}{"type":"text","timestamp":1795317800589,"sessionID":"ses_dfeb89c4cffe8b04HBWj4aUxSo","part":{"id":"prt_201479927001yBRQ2Mgzs3VaE8","messageID":"msg_20147820b001gHLqRvEH7bNrAN","sessionID":"ses_dfeb89c4cffe8b04HBWj4aUxSo","type":"text","text":"Cannot forecast: `solution.py`, `description.md`, and `input/` not found in `/home/ubuntu/.cache/styx/forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/before/work` (directory empty).\n\nRUNTIME_S=-1\nRUNTIME_S_LOW=-1\nRUNTIME_S_HIGH=-1\nPEAK_GPU_MB=-1\nTEST_RMSE=-1\nTEST_RMSE_LOW=-1\nTEST_RMSE_HIGH=-1\nREQUEST_S=-1\nSELF_SECONDS=15\nSELF_SECONDS_LOW=8\nSELF_SECONDS_HIGH=30\nSELF_OUTPUT_TOKENS=180\nSELF_OUTPUT_TOKENS_LOW=120\nSELF_OUTPUT_TOKENS_HIGH=350\nSELF_TOOL_CALLS=2\nSELF_TOOL_CALLS_LOW=2\nSELF_TOOL_CALLS_HIGH=4","time":{"start":1795317799207,"end":1795317800581}}}{"type":"step_finish","timestamp":1795317800590,"sessionID":"ses_dfeb89c4cffe8b04HBWj4aUxSo","part":{"id":"prt_201479e87001UAAZqIz4E9MsWU","reason":"stop","messageID":"msg_20147820b001gHLqRvEH7bNrAN","sessionID":"ses_dfeb89c4cffe8b04HBWj4aUxSo","type":"step-finish","tokens":{"total":5188,"input":4842,"output":191,"reasoning":155,"cache":{"write":0,"read":0}},"cost":0}}12345678910111213141516171819202122232425262728293031323.213.423.425.275.425.427.217.437.537.569.6417.0817.1220.8722.1422.1422.1422.1725.4726.6326.6426.6426.7030.0033.6333.6433.6433.6433.6637.4951.8051.801234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556{ "agent_s": 60.0, "cpu_s": 0, "late": false, "exit": 0, "host": "150-136-52-209", "tool_calls": 15, "output_tokens": 3185, "cached_tokens": 84992, "input_tokens": 51622, "cost_usd": 0, "answered": true, "runtime_err": 1.1446562271695164, "runtime_in": false, "memory_err": 0.4060903035020827, "rmse_err": 0.05606333333333334, "rmse_in": false, "request_ok": true, "request_ratio": 15.706806282722512, "peeked": false, "self_seconds_err": -1.3862943611198906, "self_output_tokens_err": -2.8732507171160533, "self_tool_calls_err": -2.0149030205422647, "self_seconds_in": false, "self_output_tokens_in": false, "self_tool_calls_in": false, "item": "direct-A100-d", "epoch": 1, "said": { "RUNTIME_S": 180.0, "RUNTIME_S_LOW": 90.0, "RUNTIME_S_HIGH": 420.0, "PEAK_GPU_MB": 800.0, "TEST_RMSE": 0.047, "TEST_RMSE_LOW": 0.035, "TEST_RMSE_HIGH": 0.07, "REQUEST_S": 900.0 }, "own": { "SELF_SECONDS": 15.0, "SELF_SECONDS_LOW": 8.0, "SELF_SECONDS_HIGH": 30.0, "SELF_OUTPUT_TOKENS": 180.0, "SELF_OUTPUT_TOKENS_LOW": 120.0, "SELF_OUTPUT_TOKENS_HIGH": 350.0, "SELF_TOOL_CALLS": 2.0, "SELF_TOOL_CALLS_LOW": 2.0, "SELF_TOOL_CALLS_HIGH": 4.0 }, "ours": { "seconds": 57.300000000000004, "peak_gpu_mb": 533.0, "test_rmse": 0.10306333333333334, "n": 3 }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
import osimport shutilimport numpy as npimport pandas as pdfrom glob import globfrom PIL import Imageimport torchimport torch.nn as nnfrom torch.utils.data import Dataset, DataLoaderfrom sklearn.model_selection import KFold, train_test_splitfrom torchvision import transformsfrom torchvision.transforms import functional as TF
# Set device and seeds for reproducibilitydevice = torch.device("cuda" if torch.cuda.is_available() else "cpu")torch.manual_seed(42)np.random.seed(42)
os.makedirs("./submission", exist_ok=True)os.makedirs("./working", exist_ok=True)
# Helper function to center crop a tensor to a target height and widthdef center_crop_tensor(tensor, target_h, target_w): _, _, h, w = tensor.shape start_h = (h - target_h) // 2 start_w = (w - target_w) // 2 return tensor[:, :, start_h : start_h + target_h, start_w : start_w + target_w]
# Define the dataset for training pairs with center cropping to common dimensionsclass DenoiseTrainDataset(Dataset): def __init__(self, noisy_files, clean_files, transform=None): self.noisy_files = noisy_files self.clean_files = clean_files self.transform = transform
def __len__(self): return len(self.noisy_files)
def __getitem__(self, idx): noisy_img = Image.open(self.noisy_files[idx]).convert("L") clean_img = Image.open(self.clean_files[idx]).convert("L") common_w = min(noisy_img.width, clean_img.width) common_h = min(noisy_img.height, clean_img.height) noisy_img = TF.center_crop(noisy_img, (common_h, common_w)) clean_img = TF.center_crop(clean_img, (common_h, common_w)) if self.transform: noisy_img = self.transform(noisy_img) clean_img = self.transform(clean_img) return noisy_img, clean_img
# Define the dataset for test imagesclass DenoiseTestDataset(Dataset): def __init__(self, test_files, transform=None): self.test_files = test_files self.transform = transform
def __len__(self): return len(self.test_files)
def __getitem__(self, idx): path = self.test_files[idx] img = Image.open(path).convert("L") if self.transform: img_tensor = self.transform(img) else: img_tensor = transforms.ToTensor()(img) # Store original dimensions for later cropping original_size = img.size[::-1] # (height, width) img_id = os.path.basename(path).split(".")[0] return img_tensor, img_id, original_size
# Define the AutoEncoder modelclass AutoEncoder(nn.Module): def __init__(self): super(AutoEncoder, self).__init__() self.encoder = nn.Sequential( nn.Conv2d(1, 16, 3, stride=2, padding=1), nn.ReLU(True), nn.Conv2d(16, 32, 3, stride=2, padding=1), nn.ReLU(True), ) self.decoder = nn.Sequential( nn.ConvTranspose2d(32, 16, 3, stride=2, padding=1, output_padding=1), nn.ReLU(True), nn.ConvTranspose2d(16, 1, 3, stride=2, padding=1, output_padding=1), nn.Sigmoid(), )
def forward(self, x): x = self.encoder(x) x = self.decoder(x) return x
transform = transforms.ToTensor()
# File pathstrain_noisy_paths = sorted(glob(os.path.join("./input/train/", "*.png")))train_clean_paths = sorted(glob(os.path.join("./input/train_cleaned/", "*.png")))test_paths = sorted(glob(os.path.join("./input/test/", "*.png")))
num_epochs = 10batch_size = 1learning_rate = 1e-3
def train_model(model, dataloader, optimizer, criterion): model.train() running_loss = 0.0 for noisy, clean in dataloader: noisy = noisy.to(device) clean = clean.to(device) optimizer.zero_grad() outputs = model(noisy) target_h, target_w = clean.shape[-2], clean.shape[-1] if outputs.shape[-2] != target_h or outputs.shape[-1] != target_w: outputs = center_crop_tensor(outputs, target_h, target_w) loss = criterion(outputs, clean) loss.backward() optimizer.step() running_loss += loss.item() * noisy.size(0) return running_loss / len(dataloader.dataset)
def validate_model(model, dataloader, criterion): model.eval() total_loss = 0.0 with torch.no_grad(): for noisy, clean in dataloader: noisy = noisy.to(device) clean = clean.to(device) outputs = model(noisy) target_h, target_w = clean.shape[-2], clean.shape[-1] if outputs.shape[-2] != target_h or outputs.shape[-1] != target_w: outputs = center_crop_tensor(outputs, target_h, target_w) loss = criterion(outputs, clean) total_loss += loss.item() * noisy.size(0) mse = total_loss / len(dataloader.dataset) rmse = np.sqrt(mse) return rmse
rmse_scores = []indices = np.arange(len(train_noisy_paths))print("Starting 5-fold cross validation...")kf = KFold(n_splits=5, shuffle=True, random_state=42)for fold, (train_idx, val_idx) in enumerate(kf.split(indices)): print(f"Fold {fold+1}") train_noisy = [train_noisy_paths[i] for i in train_idx] train_clean = [train_clean_paths[i] for i in train_idx] val_noisy = [train_noisy_paths[i] for i in val_idx] val_clean = [train_clean_paths[i] for i in val_idx] train_dataset = DenoiseTrainDataset(train_noisy, train_clean, transform=transform) val_dataset = DenoiseTrainDataset(val_noisy, val_clean, transform=transform) train_loader = DataLoader(train_dataset, batch_size=batch_size, shuffle=True) val_loader = DataLoader(val_dataset, batch_size=batch_size, shuffle=False)
model = AutoEncoder().to(device) optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate) criterion = nn.MSELoss() for epoch in range(num_epochs): train_loss = train_model(model, train_loader, optimizer, criterion) fold_rmse = validate_model(model, val_loader, criterion) print(f"Fold {fold+1} RMSE: {fold_rmse:.4f}") rmse_scores.append(fold_rmse)
avg_cv_rmse = np.mean(rmse_scores)print(f"Average 5-fold CV RMSE: {avg_cv_rmse:.4f}")
# Split training data for final hold-out evaluationnoisy_train, noisy_holdout, clean_train, clean_holdout = train_test_split( train_noisy_paths, train_clean_paths, test_size=0.1, random_state=42)
full_dataset = DenoiseTrainDataset(noisy_train, clean_train, transform=transform)full_loader = DataLoader(full_dataset, batch_size=batch_size, shuffle=True)final_model = AutoEncoder().to(device)optimizer = torch.optim.Adam(final_model.parameters(), lr=learning_rate)criterion = nn.MSELoss()print("Training final model on hold-out training data...")for epoch in range(num_epochs): train_loss = train_model(final_model, full_loader, optimizer, criterion) print(f"Final Model Epoch {epoch+1} Loss: {train_loss:.4f}")
holdout_dataset = DenoiseTrainDataset(noisy_holdout, clean_holdout, transform=transform)holdout_loader = DataLoader(holdout_dataset, batch_size=1, shuffle=False)holdout_rmse = validate_model(final_model, holdout_loader, criterion)print(f"Hold-out Validation RMSE: {holdout_rmse:.4f}")
# Generate predictions on test images and create submission filefinal_model.eval()submission_frames = []with torch.no_grad(): for test_file in test_paths: img_basename = os.path.basename(test_file).split(".")[0] img = Image.open(test_file).convert("L") original_h, original_w = ( img.size[1], img.size[0], ) # PIL size is (width, height) so switching to (h,w) test_tensor = transform(img).unsqueeze(0).to(device) output_tensor = final_model(test_tensor) out_h, out_w = output_tensor.shape[-2], output_tensor.shape[-1] if out_h != original_h or out_w != original_w: output_tensor = center_crop_tensor(output_tensor, original_h, original_w) # Convert output tensor to numpy array and squeeze channel dimension output_img = output_tensor.squeeze().cpu().numpy() # shape = (H, W) # Clip and vectorize creation of submission entries output_img = np.clip(output_img, 0, 1) h, w = output_img.shape rows, cols = np.indices((h, w)) rows = rows.flatten() + 1 # 1-indexed cols = cols.flatten() + 1 pixel_vals = output_img.flatten() # Create ids vectorized ids = np.char.add( np.char.add(np.char.add(img_basename, "_"), rows.astype(str)), np.char.add("_", cols.astype(str)), ) temp_df = pd.DataFrame({"id": ids, "value": pixel_vals}) submission_frames.append(temp_df)
submission_df = pd.concat(submission_frames, ignore_index=True)submission_csv_path = "./submission/submission.csv"submission_df.to_csv(submission_csv_path, index=False)print(f"Submission file saved at '{submission_csv_path}'")
working_submission_path = "./working/submission.csv"shutil.copy(submission_csv_path, working_submission_path)print(f"Submission file copied to '{working_submission_path}'")
print(f"Final Hold-out RMSE for evaluation: {holdout_rmse:.4f}")forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/before/clock.txtAdded+9
forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/before/transcript.jsonlAdded+9
forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/clock.txtAdded+32
forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/episode.jsonAdded+56
forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/stderr.txtAdded
forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/transcript.jsonlAdded
forecast/20261122-5a18eab/opencode-opencode_big-pickle/direct-A100-d-1/work/solution.pyAdded+237