File size: 1,111 Bytes
0130f3f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Patch for flamingo_lm.py line 177
# Change: return super().forward(**kwargs)
# To: return super().forward(**{k: v for k, v in kwargs.items() if k != 'labels'})

import sys
original_file = '/home/user/app/open_flamingo/src/flamingo_lm.py'

with open(original_file, 'r') as f:
    content = f.read()

# Replace the problematic line
old_line = "return super().forward(**kwargs)  # Call the other parent's forward method"
new_line = "return super().forward(**{k: v for k, v in kwargs.items() if k != 'labels'})  # Remove labels"

if old_line in content:
    content = content.replace(old_line, new_line)
    with open(original_file, 'w') as f:
        f.write(content)
    print("✅ Patched flamingo_lm.py")
else:
    print("⚠️  Line not found, trying alternative...")
    # Try without comment
    old_line = "return super().forward(**kwargs)"
    new_line = "return super().forward(**{k: v for k, v in kwargs.items() if k != 'labels'})"
    content = content.replace(old_line, new_line)
    with open(original_file, 'w') as f:
        f.write(content)
    print("✅ Patched flamingo_lm.py (alternative)")