TIBHannover / MSVA

Deep learning model for supervised video summarization called Multi Source Visual Attention (MSVA)
MIT License
41 stars 18 forks source link

Request for changes in `train.py` and `knapsack.py` #14

Open rodosingh opened 1 year ago

rodosingh commented 1 year ago

ThankYou MSVA guys, for making the code public and most importantly, the splits public.


After trying to reproduce your code, I encountered two errors (Line 314)

train_val_loss_score.append([loss,np.mean(avg_loss[:, 0]),val_fscore,test_loss, video_scores,kt,sp])

Appending the loss and test_loss (both being torch.cuda.Tensor) creates an issue (can't convert cuda tensor to numpy array) while converting them to numpy array at Line 538.

Additional INFO:

According to current version of ortools the code will be:

from ortools.algorithms.python import knapsack_solver

osolver = knapsack_solver.KnapsackSolver(
    knapsack_solver.KNAPSACK_DYNAMIC_PROGRAMMING_SOLVER,
    'test')

def knapsack_ortools(values, weights, items, capacity ):
    scale = 1000
    values = np.array(values)
    weights = np.array(weights)
    values = (values * scale).astype(np.int)
    weights = (weights).astype(np.int)
    capacity = capacity
    osolver.init(values.tolist(), [weights.tolist()], [capacity])
    computed_value = osolver.solve()
    packed_items = [x for x in range(0, len(weights))
                    if osolver.best_solution_contains(x)]
    return packed_items

Thanks 😺