Xeexeex commited on
Commit
1686d38
·
verified ·
1 Parent(s): 58cfc96

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from torchvision import transforms
3
+ from PIL import Image
4
+ from huggingface_hub import hf_hub_download
5
+
6
+ # Download model dari repo Anda
7
+ repo_id = "USERNAME_ANDA/GeoX-Custom-Model"
8
+ path = hf_hub_download(repo_id=repo_id, filename="pytorch_model.bin")
9
+
10
+ # Load ke arsitektur
11
+ model = GeoXModel() # Gunakan class yang sama dengan di atas
12
+ model.load_state_dict(torch.load(path))
13
+ model.eval()
14
+
15
+ # Prediksi foto baru
16
+ def predict(img_path):
17
+ img = Image.open(img_path).convert('RGB')
18
+ preprocess = transforms.Compose([transforms.Resize(224), transforms.ToTensor()])
19
+ img_t = preprocess(img).unsqueeze(0)
20
+
21
+ with torch.no_grad():
22
+ out = model(img_t)
23
+ print(f"Hasil Prediksi Koordinat: {out.numpy()}")
24
+
25
+ predict("test_foto.jpg")