Update app.py
Browse files
app.py
CHANGED
@@ -18,16 +18,16 @@ model = AutoModelForImageTextToText.from_pretrained(
|
|
18 |
model_id,
|
19 |
# load_in_4bit=True,
|
20 |
torch_dtype=torch.float32 if device.type == "cpu" else torch.bfloat16,
|
21 |
-
device_map=
|
22 |
).to(device)
|
23 |
|
24 |
-
if device.type == "cuda":
|
25 |
-
|
26 |
-
|
27 |
|
28 |
processor = AutoProcessor.from_pretrained(model_id)
|
29 |
|
30 |
-
@spaces.GPU(duration=120)
|
31 |
# Function to process the image and generate the description
|
32 |
def generate_description(image: Image.Image, instruction: str):
|
33 |
|
|
|
18 |
model_id,
|
19 |
# load_in_4bit=True,
|
20 |
torch_dtype=torch.float32 if device.type == "cpu" else torch.bfloat16,
|
21 |
+
device_map=device,
|
22 |
).to(device)
|
23 |
|
24 |
+
# if device.type == "cuda":
|
25 |
+
# model.gradient_checkpointing_enable()
|
26 |
+
model.gradient_checkpointing_enable()
|
27 |
|
28 |
processor = AutoProcessor.from_pretrained(model_id)
|
29 |
|
30 |
+
# @spaces.GPU(duration=120)
|
31 |
# Function to process the image and generate the description
|
32 |
def generate_description(image: Image.Image, instruction: str):
|
33 |
|