File size: 751 Bytes
1686d38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import torch
from torchvision import transforms
from PIL import Image
from huggingface_hub import hf_hub_download

# Download model dari repo Anda
repo_id = "USERNAME_ANDA/GeoX-Custom-Model"
path = hf_hub_download(repo_id=repo_id, filename="pytorch_model.bin")

# Load ke arsitektur
model = GeoXModel() # Gunakan class yang sama dengan di atas
model.load_state_dict(torch.load(path))
model.eval()

# Prediksi foto baru
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")