fohy24
commited on
Commit
·
c18a023
1
Parent(s):
8f57166
trial
Browse files
app.py
CHANGED
@@ -56,19 +56,20 @@ def predict(img, confidence):
|
|
56 |
|
57 |
# Download model from GCS
|
58 |
model_path = os.getenv('MODEL_PATH')
|
|
|
59 |
response = requests.get(model_path)
|
60 |
time.sleep(20)
|
61 |
|
62 |
-
# Define the cache directory path
|
63 |
-
cache_dir = os.path.expanduser("~/.cache/torch/hub/checkpoints")
|
64 |
-
model_file_name = os.path.basename(model_path)
|
65 |
-
model_file_path = os.path.join(cache_dir, model_file_name)
|
66 |
-
print(model_file_path)
|
67 |
|
68 |
-
with open(
|
69 |
f.write(response.content)
|
70 |
|
71 |
-
checkpoint = torch.load(
|
72 |
densenet.load_state_dict(checkpoint['model_state_dict'])
|
73 |
|
74 |
densenet.eval()
|
|
|
56 |
|
57 |
# Download model from GCS
|
58 |
model_path = os.getenv('MODEL_PATH')
|
59 |
+
print(model_path)
|
60 |
response = requests.get(model_path)
|
61 |
time.sleep(20)
|
62 |
|
63 |
+
# # Define the cache directory path
|
64 |
+
# cache_dir = os.path.expanduser("~/.cache/torch/hub/checkpoints")
|
65 |
+
# model_file_name = os.path.basename(model_path)
|
66 |
+
# model_file_path = os.path.join(cache_dir, model_file_name)
|
67 |
+
# print(model_file_path)
|
68 |
|
69 |
+
with open('model.pt', 'wb') as f:
|
70 |
f.write(response.content)
|
71 |
|
72 |
+
checkpoint = torch.load('model.pt', map_location=device)
|
73 |
densenet.load_state_dict(checkpoint['model_state_dict'])
|
74 |
|
75 |
densenet.eval()
|