Use relative path

This commit is contained in:
Vincentzyx 2021-07-28 21:08:33 +08:00
parent fa11fa7cfc
commit 5057b0dfa9
4 changed files with 15 additions and 15 deletions

View File

@ -57,11 +57,11 @@ net = Net()
net.eval() net.eval()
if UseGPU: if UseGPU:
net = net.to(device) net = net.to(device)
if os.path.exists("bid_weights.pkl"): if os.path.exists("./bid_weights.pkl"):
if torch.cuda.is_available(): if torch.cuda.is_available():
net.load_state_dict(torch.load('bid_weights.pkl')) net.load_state_dict(torch.load('./bid_weights.pkl'))
else: else:
net.load_state_dict(torch.load('bid_weights.pkl', map_location=torch.device("cpu"))) net.load_state_dict(torch.load('./bid_weights.pkl', map_location=torch.device("cpu")))
def predict(cards): def predict(cards):
input = RealToOnehot(cards) input = RealToOnehot(cards)

View File

@ -53,17 +53,17 @@ class Net(nn.Module):
return x return x
Nets = {"up": Net(), "down": Net()} Nets = {"up": Net(), "down": Net()}
if os.path.exists("landlord_up_weights.pkl"): if os.path.exists("./landlord_up_weights.pkl"):
if torch.cuda.is_available(): if torch.cuda.is_available():
Nets["up"].load_state_dict(torch.load("landlord_up_weights.pkl")) Nets["up"].load_state_dict(torch.load("./landlord_up_weights.pkl"))
else: else:
Nets["up"].load_state_dict(torch.load("landlord_up_weights.pkl", map_location=torch.device("cpu"))) Nets["up"].load_state_dict(torch.load("./landlord_up_weights.pkl", map_location=torch.device("cpu")))
Nets["up"].eval() Nets["up"].eval()
if os.path.exists("landlord_down_weights.pkl"): if os.path.exists("./landlord_down_weights.pkl"):
if torch.cuda.is_available(): if torch.cuda.is_available():
Nets["up"].load_state_dict(torch.load("landlord_down_weights.pkl")) Nets["up"].load_state_dict(torch.load("./landlord_down_weights.pkl"))
else: else:
Nets["up"].load_state_dict(torch.load("landlord_down_weights.pkl", map_location=torch.device("cpu"))) Nets["up"].load_state_dict(torch.load("./landlord_down_weights.pkl", map_location=torch.device("cpu")))
Nets["down"].eval() Nets["down"].eval()
def predict(cards, llc, type="up"): def predict(cards, llc, type="up"):

View File

@ -155,11 +155,11 @@ class GameHelper:
self.PicsCV = {} self.PicsCV = {}
self.Handle = win32gui.FindWindow("Hlddz", None) self.Handle = win32gui.FindWindow("Hlddz", None)
self.Interrupt = False self.Interrupt = False
for file in os.listdir("pics"): for file in os.listdir("./pics"):
info = file.split(".") info = file.split(".")
if info[1] == "png": if info[1] == "png":
tmpImage = Image.open("pics/" + file) tmpImage = Image.open("./pics/" + file)
imgCv = cv2.imread("pics/" + file) imgCv = cv2.imread("./pics/" + file)
self.Pics.update({info[0]: tmpImage}) self.Pics.update({info[0]: tmpImage})
self.PicsCV.update({info[0]: imgCv}) self.PicsCV.update({info[0]: imgCv})

View File

@ -53,11 +53,11 @@ class Net(nn.Module):
net = Net() net = Net()
net.eval() net.eval()
if os.path.exists("landlord_weights.pkl"): if os.path.exists("./landlord_weights.pkl"):
if torch.cuda.is_available(): if torch.cuda.is_available():
net.load_state_dict(torch.load('landlord_weights.pkl')) net.load_state_dict(torch.load('./landlord_weights.pkl'))
else: else:
net.load_state_dict(torch.load('landlord_weights.pkl', map_location=torch.device("cpu"))) net.load_state_dict(torch.load('./landlord_weights.pkl', map_location=torch.device("cpu")))
else: else:
print("landlord_weights.pkl not found") print("landlord_weights.pkl not found")