m7mdal7aj commited on
Commit
8e2f248
1 Parent(s): 8a94bf7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -33,12 +33,15 @@ def answer_question(image, question, model, processor):
33
 
34
 
35
  image = Image.open(image)
36
-
37
-
38
 
39
  inputs = processor(image, question, return_tensors="pt").to("cuda", torch.float16)
40
 
41
- out = model.generate(**inputs, max_length=200, min_length=20)
 
 
 
 
 
42
 
43
  answer = processor.decode(out[0], skip_special_tokens=True).strip()
44
  return answer
 
33
 
34
 
35
  image = Image.open(image)
 
 
36
 
37
  inputs = processor(image, question, return_tensors="pt").to("cuda", torch.float16)
38
 
39
+ if isinstance(model, torch.nn.DataParallel):
40
+ # Use the 'module' attribute to access the original model
41
+ out = model.module.generate(**inputs)
42
+ else:
43
+
44
+ out = model.generate(**inputs, max_length=200, min_length=20)
45
 
46
  answer = processor.decode(out[0], skip_special_tokens=True).strip()
47
  return answer