FastSAM icon indicating copy to clipboard operation
FastSAM copied to clipboard

how can i load the fastsam model in float16 ??

Open dahwin opened this issue 1 year ago • 0 comments

**%cd /content/FastSAM import torch from PIL import Image import matplotlib.pyplot as plt from fastsam import FastSAM, FastSAMPrompt

Set up parameters

model_path = "/content/FastSAM.pt" img_path = "/content/grid.png" device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

Load model

model = FastSAM(model_path)

Load and process image

input_image = Image.open(img_path).convert("RGB")

Run inference

everything_results = model( input_image, device=device, retina_masks=True, imgsz=1024, conf=0.4, iou=0.9 )

Process results

prompt_process = FastSAMPrompt(input_image, everything_results, device=device) ann = prompt_process.everything_prompt()

Plot results

result_image = prompt_process.plot( annotations=ann, withContours=True, better_quality=True, output_path='dahyun.png' )**

dahwin avatar Jun 28 '24 03:06 dahwin