|
|
import torch |
|
|
from torchvision import transforms |
|
|
from PIL import Image |
|
|
from huggingface_hub import hf_hub_download |
|
|
|
|
|
|
|
|
repo_id = "USERNAME_ANDA/GeoX-Custom-Model" |
|
|
path = hf_hub_download(repo_id=repo_id, filename="pytorch_model.bin") |
|
|
|
|
|
|
|
|
model = GeoXModel() |
|
|
model.load_state_dict(torch.load(path)) |
|
|
model.eval() |
|
|
|
|
|
|
|
|
def predict(img_path): |
|
|
img = Image.open(img_path).convert('RGB') |
|
|
preprocess = transforms.Compose([transforms.Resize(224), transforms.ToTensor()]) |
|
|
img_t = preprocess(img).unsqueeze(0) |
|
|
|
|
|
with torch.no_grad(): |
|
|
out = model(img_t) |
|
|
print(f"Hasil Prediksi Koordinat: {out.numpy()}") |
|
|
|
|
|
predict("test_foto.jpg") |