silveroxides commited on
Commit
a877264
1 Parent(s): 5cf3d8f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -9,7 +9,13 @@ import gradio as gr
9
  import PIL.Image
10
  import spaces
11
  import torch
12
- from transformers import AutoProcessor, Blip2ForConditionalGeneration
 
 
 
 
 
 
13
 
14
  DESCRIPTION = "# [BLIP-2](https://github.com/salesforce/LAVIS/tree/main/projects/blip2)"
15
 
@@ -27,7 +33,7 @@ assert MODEL_ID in [MODEL_ID_OPT_2_7B, MODEL_ID_OPT_6_7B, MODEL_ID_FLAN_T5_XL, M
27
 
28
  if torch.cuda.is_available():
29
  processor = AutoProcessor.from_pretrained(MODEL_ID)
30
- model = Blip2ForConditionalGeneration.from_pretrained(MODEL_ID, device_map="auto", load_in_8bit=True)
31
 
32
 
33
  @spaces.GPU
 
9
  import PIL.Image
10
  import spaces
11
  import torch
12
+ from transformers import AutoProcessor, BitsAndBytesConfig, Blip2ForConditionalGeneration
13
+
14
+ from transformers import BitsAndBytesConfig
15
+
16
+ bnb_config = BitsAndBytesConfig(
17
+ load_in_8bit=True,
18
+ )
19
 
20
  DESCRIPTION = "# [BLIP-2](https://github.com/salesforce/LAVIS/tree/main/projects/blip2)"
21
 
 
33
 
34
  if torch.cuda.is_available():
35
  processor = AutoProcessor.from_pretrained(MODEL_ID)
36
+ model = Blip2ForConditionalGeneration.from_pretrained(MODEL_ID, device_map="auto", quantization_config=bnb_config)
37
 
38
 
39
  @spaces.GPU