yelusaleng / RRU-Net

Official repository for "RRU-Net: The Ringed Residual U-Net for Image Splicing Forgery Detection" (CVPRW 2019)
106 stars 17 forks source link

Bug #32

Open littlealili opened 1 year ago

littlealili commented 1 year ago

When I try to debug the train.py, I meet the problem. Can you tell me the reason? Thank you! for i, b in enumerate(batch(train, batch_size)): start_batch = time.time() imgs = np.array([i[0] for i in b]).astype(np.float32) true_masks = np.array([i[1] for i in b]).astype(np.float32) / 255.

        imgs = torch.from_numpy(imgs)
        true_masks = torch.from_numpy(true_masks)

        if gpu:
            imgs = imgs.cuda()
            true_masks = true_masks.cuda()

        optimizer.zero_grad()

        masks_pred = net(imgs)
        masks_probs = torch.sigmoid(masks_pred)
        masks_probs_flat = masks_probs.view(-1)
        true_masks_flat = true_masks.view(-1)
        loss = criterion(masks_probs_flat, true_masks_flat)

        print('{:.4f} --- loss: {:.4f}, {:.3f}s'.format(i * batch_size / N_train, loss, time.time()-start_batch))

        epoch_loss += loss.item()

        loss.backward()
        optimizer.step()
    print('Epoch finished ! Loss: {:.4f}'.format(epoch_loss / i))

local variable 'i' referenced before assignment

yelusaleng commented 1 year ago

hi, check the Indenting and Whitespace